Get a synchronized (thread-safe) wrapper for a SortedList in CSharp
Description
The following code shows how to get a synchronized (thread-safe) wrapper for a SortedList.
Example
using System;/*from w ww. ja v a2s . co m*/
using System.Collections;
public class SamplesSortedList {
public static void Main() {
SortedList mySL = new SortedList();
mySL.Add( 2, "two" );
mySL.Add( 3, "three" );
mySL.Add( 1, "one" );
mySL.Add( 0, "zero" );
mySL.Add( 4, "four" );
SortedList mySyncdSL = SortedList.Synchronized( mySL );
Console.WriteLine(mySL.IsSynchronized);
Console.WriteLine(mySyncdSL.IsSynchronized);
}
}
The code above generates the following result.