> Can you verify that the critical section is successfully created > inside the > ctor?
What ctor? I can't get to the ctor of the CCriticalSection itself. Since it's a member of a structure and that structure is allocated globally (not part of a class), there is no other relevant ctor. > > first before I worry about efficiency - but I'm open to better > > suggestions of MFC (not ATL, > > sorry) objects to use for a queue). > > Well, switch to std::queue which truly represents a FIFO queue. Use > std::stack is LIFO is the behavior you need. Sorry, you must have missed the part where I said 'MFC'. > > Accordingly, in the thread (and where it tries to add things to the > > queue), I try: > > > > if (psQueue->CriticalSection.Lock(1000) ) { > > // Do something thread-safely... > > > > psQueue->Unlock(); > > } > > > > > > But when I run the program, it access violates at the .Lock() line. > > That shouldn't happen. Can you step through the Lock( ) call and > see if the > m_crit member of the CCriticalSection object is correctly set? It won't let me; psQueue claims to be valid and the members show correctly (which appears to indicate that it has been allocated in memory correctly), but the debugger just won't let me single step into Lock(). However, there is something that may explain it. The object of Class A that creates this worker thread is declared globally, as is the structure holding the critical section... is it possible that although the debugger seems to show the structure correctly, it is actually not allocated in memory at the time the thread tries to first access it, and so this is causing the problem? In other words, am I trying to use it before I can guarantee that all global objects / structures are ready? If so, then this is probably the root of my problem and I have to rethink the strategy. -- Jason Teagle [EMAIL PROTECTED]