> I /think/ my problem was that the CCriticalSection needs to > be constructed > from within the thread that wants to protect the resource. By > constructing > one within the worker thread routine itself and locking it, and also > constructing a different one (both on the stack) in the > routine adding items > to the queue, it suddenly works! > > I can understand this logic a little, since the whole point > is that the > critical section is protecting the thread from interruption, > so of course it > must be created in the thread that needs protecting.
Well, that's not my understanding. I construct the CCriticalSection once when the class is instantiated, and it doesn't matter what thread does that. I think that you may be using two different CCriticalSection objects, in which case you are not protecting anything.
