Re: [ADVANCED-DOTNET] Problem getting IStorage pointer

2006-04-05 Thread John Whattam
Thanks for your help. I've decided to use an OLE Structured Storage library from Eduardo Morcillo's site (http://www.mvps.org/emorcillo/en/index.shtml). I modified the library so the IStorage pointer returning function is made public rather than a friend function. This appears to work - a storage f

Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread Shawn Wildermuth
If you have access to Jeffrey Richter's new book "CLR via C#", he covers the in's and out's of this very problem. If you do use a RWL, make sure you lock on the synchronization object, not the instance of the object or the type. Thanks, Shawn Wildermuth http://adoguy.com C# MVP, MCSD.NET, Author

Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread Peter Ritchie
>From the Dictionary<> documentation: "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 c

Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread Ryan Heath
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 work

Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread Eric Means
Just take a lock (read or write, depending) on the Dictionary object (the actual object, not the type) before you call its methods and you should be fine. If you run into performance issues, then you can look at more granular locking or another strategy, but locking the object before any use is de

Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread James Berry
I think I probably do require reads to be blocked during a write - but specifically, I don't know how Dictionary works so I wasn't clear on how much locking I should be doing. Best wishes James -Original Message- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Beha

Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread Peter Ritchie
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 ReaderWriterL

Re: [ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread Eric Means
ReaderWriterLock? On 4/5/06, James Berry <[EMAIL PROTECTED]> wrote: > > Hi > > I have a Dictionary > > 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 concurren

[ADVANCED-DOTNET] Dictionary multi-reader single writer

2006-04-05 Thread James Berry
Hi I have a Dictionary 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? Bes