Home All Groups Group Topic Archive Search About

Re: framework 1.1 & Queue class

Author
24 Apr 2007 1:21 PM
Brian Gideon
On Apr 24, 4:56 am, Hermit Dave <herm...@newsgroup.nospam> wrote:
> I forgot to add that i do not wish to enumerate using foreach or using
> IEnumerator
>
> I would like to use Enqueue and Dequeue functions. Does the use of
> Queue.Syncronized wrapper make them threadsafe ? or would i be better of
> using
> lock( myCollection.SyncRoot ) before calling Enqueue or Dequeue methods on
> the syncronised wrapper ?
>
> --
> Regards,
>
> Hermit Davehttp://www.invokeit.co.uk

Yes, Queue.Synchronized will make the Enqueue and Dequeue methods
thread-safe.  It does this by wrapping the calls with a lock statement
against the SyncRoot property for you.  In other words, you could use
the lock statement to achieve the same thing.

AddThis Social Bookmark Button