Synchronized Method for a Collection

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
 
N

Nick Hall

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
 
F

fred

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top