OO_Dev Newbie

Joined: 20 Sep 2010 Posts: 1
|
Posted: Tue Sep 21, 2010 12:05 am Post subject: Extension development and multithreading |
|
|
Hi!
I have a problem with one of the extensions (C++/Win) I'm trying to write. In this component I need to use an external DLL, which in turns calls COM component, and, because of that, requires COM to be initialized.
Since I can't call CoInitialize on the application thread, I have a worker thread that I use for work items, and I schedule work items to that thread. So far, the main functionality works without any problems, but the problem appears when I want to do a cleanup.
As far as I understand, the components disposing function is the place you should do all the cleanup (destructor gets called even later), but unfortunately, by the time it gets there, my worker thread is long gone. And the weird thing is that it doesn't return through the (return 0;), and I can't catch a call to TerminateThread or ExitThread(RtlExitUserThread), although, the Visual Studio debugger reports that the thread has exited with retval 0x0 before I stop inside disposing function.
By the time I reach disposing, there seems to be only 1 thread left.
Who or what is closing the worker threads and how do I do the worker thread shutdown? |
|