Re: CWorkerThread and IWorkerThreadClient not working in my ATL COM server code

Tech-Archive recommends: Fix windows errors by optimizing your registry



Igor Tandetnik wrote:
"Edward Diener" <eddielee_no_spam_here@xxxxxxxxxxxxxx> wrote in message
news:%23mbcXuwBJHA.4932@xxxxxxxxxxxxxxxxxxxx
workerThread = new CWorkerThread<>;
workerThread ->
AddTimer(1,workerThreadImpl,reinterpret_cast<DWORD_PTR>(data),&workerThreadHandle);

AddTimer doesn't return a handle to the worker thread, but a handle to a waitable timer (see CreateWaitableTimer). Why you believed otherwise is beyond me. The handle gets signaled after 1 ms.

OK, my sheer stupidity but...

I do not understand the AddHandle member function. I am just trying to start a new thread on which to run my background processing. In the AddHandle call it says it takes a waitable handle as the first parameter. Huh ? Where does this handle come from ?

If I do a CreateThread I am returned a handle and can start a new thread .. How do I do the equivalent with CWorkerThread ? I thought I understand how this works but evidently I do not. I would have thought I get back a handle when I start the thread, as in CreateThread, but evidently I must pass a handle initialized from something.

The description of CWorkerThread says:

"This class creates a worker thread or uses an existing one, waits on one or more kernel object handles, and executes a specified client function when one of the handles is signaled."

I am not interested in signaling a handle just to run my worker thread. I just want to run my worker thread and be on my way. Maybe I am just using the wrong functionality and should go back to CreateThread ( or _beginthreadex since I am using C++ ), but I thought that if I program with ATL I should use this neat ATL functionality.
.



Relevant Pages

  • Re: WinDbg dt (Display Types) Issue
    ... '~*' was issued after CreateThread(). ... Process Explorer does in fact show the ... main thread and a worker thread. ... dt _ETHREAD 0x7ffdd000 ...
    (microsoft.public.win32.programmer.kernel)
  • Re: returning from worker thread
    ... SuspendThread is bad. ... The problem is that it has only one means of signaling, ... For the worker thread case like you have now ... the new thread function would look about like this... ...
    (microsoft.public.vc.mfc)
  • Re: Best/fastest way to abort worker thread
    ... event is set signaling the worker thread to stop processing. ... Does anyone now of a more fail safe method to successfully kill a ongoing ... _calcThread = new Thread); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Best/fastest way to abort worker thread
    ... event is set signaling the worker thread to stop processing. ... Does anyone now of a more fail safe method to successfully kill a ongoing ... _calcThread = new Thread); ...
    (microsoft.public.dotnet.languages.csharp)