At the moment, design is: thread is launched, and waits on event. When there's something to do (aka a com service to perform), main thread sets up some stuff (mainly a pointer to a object that knows how to do that service), sets the event that gets the worker thread out of its wait, and then itself waits on another event. When the worker thread has finished it's thing, it sets the event that lets the main thread run, and goes back to waiting for the next thing to do.
Finishing is just "another thing to do" for the worker thread, and follows same pattern. --- In [email protected], "brucexs" <bswit...@...> wrote: > > For some reason WaitForSingleObject(hThread) locks up. I'll try > > CoWaitForMultipleHandles with hThread. > Possibly the code in the file plug-in in dll_detach may be give you some > helpful ideas. It is shutting down any threads which are in wait state from > file.runwait. I get by waiting for the "there's stuff to do" event in the worker thread. In the special case where the pointer to the object that knows what specifiically to do is null pointer, the thread ends. > I understand that you have the same situation that a worker thread may be in > the wait state and you need to shut it down. This code does that. > If your worker thread is not normally in the wait state, then would need to > augment this idea. For PowerPro, if the thread happened not to be in the > wait state, now that I look at it, there is actually a potential deadlock, > since the thread's function could sendmessage to powerpro itself (ie the > thread that has just send an event and is now wait for thread to die). I > should be checking for the unload event before that, but it seems this error > has never been reported so I am assuming it is too rare to worry about. > Possibly not the situation for you. There may be some nastiness if I've left some com object around created on the worker thread. I've tried to make sure I release every such object, but if I've missed something that may prevent thread from dying. Can;t find and documentation to support that though.
