I'd like to add Ian's blog to the ReaderWriterLock suggestion http://www.interact-sw.co.uk/iangblog/2004/04/26/rwlockvsmonitor
On 4/5/06, James Berry <[EMAIL PROTECTED]> wrote: > I think I probably do require reads to be blocked during a write - but > specifically, I don't know how Dictionary<X,Y> works so I wasn't clear > on how much locking I should be doing. from msdn: A Dictionary can support multiple readers concurrently, as long as the collection is not modified. Even so, enumerating through a collection is intrinsically not a thread-safe procedure. In the rare case where an enumeration contends with write accesses, the collection must be locked during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. HTH // Ryan > > Best wishes > James > > > -----Original Message----- > From: Discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of Peter Ritchie > Sent: 05 April 2006 18:50 > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer > > I, too, assumed James would require reads to be blocked during a write; > making ReaderWriterLock an excellent candidate. > > Vance Morrison has a good blog entry on ReaderWriterLock (which also > references some of his excellent articles on multi-threading) that > discusses the performance of ReaderWriterLock in .NET 2.0 (and, I'll > assume, 1.x) [1] > > [1] http://blogs.msdn.com/vancem/archive/2006/03/28/563180.aspx > > -- Peter > _____ > http://www.peterRitchie.com/Blog/DotNetConfig.xsd > > On Wed, 5 Apr 2006 12:17:25 -0500, Eric Means <[EMAIL PROTECTED]> > wrote: > > >ReaderWriterLock? > > > >On 4/5/06, James Berry <[EMAIL PROTECTED]> wrote: > >> > >> Hi > >> > >> I have a Dictionary<X,Y> > >> > >> I want to look up X's in my dictionary a lot from multiple threads. > >> I want to add items to my dictionary occasionally from some of these > >> threads. I would like the reads to proceed concurrently without > >> locking, but I am not sure of the right pattern - can anyone help? > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com