Get an object that can be used to synchronize access to the Hashtable in CSharp
Description
The following code shows how to get an object that can be used to synchronize access to the Hashtable.
Example
using System.Collections;
using System;/*w w w .j a va2s. c o m*/
public class MainClass{
public static void Main(String[] argv){
Hashtable myCollection = new Hashtable();
lock(myCollection.SyncRoot)
{
foreach (object item in myCollection)
{
// Insert your code here.
Console.WriteLine("code");
}
}
}
}