Return a synchronized (thread-safe) wrapper for the Hashtable in CSharp
Description
The following code shows how to return a synchronized (thread-safe) wrapper for the Hashtable.
Example
using System;/*from ww w.ja v a 2 s . c om*/
using System.Collections;
public class SamplesHashtable {
public static void Main() {
Hashtable myHT = new Hashtable();
myHT.Add( 0, "zero" );
myHT.Add( 1, "one" );
myHT.Add( 2, "two" );
Hashtable mySyncdHT = Hashtable.Synchronized( myHT );
Console.WriteLine(myHT.IsSynchronized);
Console.WriteLine(mySyncdHT.IsSynchronized);
}
}
The code above generates the following result.