try this ...
Hashtable ht = Hashtable.Synchronized( new Hashtable() );
Regards,
Ralf
Ralf Stanke
[VENTUZ] The future of presentations
www.ventuz.com
"Aaron Pfeifer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It doesn't seem completely clear to me which operations I can perform
> while continuing to be thread-safe on a Hashtable. Consider this
> scenario:
>
> Hashtable 'table' contains the following:
> table[1] = 1
> table[2] = 2
> table[...] = ...
> table[Int32.MaxValue] = Int32.MaxValue
>
> The following threads are now running against that same table
>
> Thread 1:
> for( int i = -1; i > Int32.MinValue; i-- )
> {
> table.Add( i, i );
> }
>
> Thread 2:
> for( int i = 1; i < Int32.MaxValue; i++ )
> {
> table.Remove( i );
> }
>
> Thread 3:
> while( true )
> {
> IList list = new ArrayList( table.Keys );
> foreach( int number in list )
> {
> Console.WriteLine( number );
> }
> }
>
>
> Obviously this is unusual, but it's something like what I actually have,
> and I want to know whether or not this is thread-safe or if I need to
> provide some synchronization. Thanks!
>