C# SortedList Synchronized
Description
SortedList Synchronized
returns a synchronized (thread-safe)
wrapper for a SortedList object.
Syntax
SortedList.Synchronized
has the following syntax.
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true)]
public static SortedList Synchronized(
SortedList list
)
Parameters
SortedList.Synchronized
has the following parameters.
list
- The SortedList object to synchronize.
Returns
SortedList.Synchronized
method returns A synchronized (thread-safe) wrapper for the SortedList object.
Example
The following code example shows how to synchronize a SortedList object, determine whether a SortedList is synchronized, and use a synchronized SortedList.
using System;//w w w . j a v a2 s. c o 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.