Synchronized Method for a Collection

  • Thread starter Thread starter fred
  • Start date Start date
F

fred

I have created a Collection class inherited from the CollectionBase Class.

How would I implement a Synchronized method similar to the Synchronised
method of the HashTable Class.

Thanks,
Fred
 
Fred,

There are a number of ways you COULD do it. HashTable defines a private
class which inherits from Hashtable and overrides the key methods (Add,
Clear etc). It implements the methods by performing the relevant actions in
a SyncLock block. The Synchronised method returns an instance of this
class.

Hope this helps,

Nick Hall
 
Thanks Nick.
Nick Hall said:
Fred,

There are a number of ways you COULD do it. HashTable defines a private
class which inherits from Hashtable and overrides the key methods (Add,
Clear etc). It implements the methods by performing the relevant actions in
a SyncLock block. The Synchronised method returns an instance of this
class.

Hope this helps,

Nick Hall
 
Back
Top