Re: CWorkerThread and IWorkerThreadClient not working in my ATL COM server code
"Edward Diener" <eddielee_no_spam_here@tropicsoft.com> wrote in message
news:OyX0cBzBJHA.3496@TK2MSFTNGP03.phx.gbl
I do not understand the AddHandle member function. I am just trying to
start a new thread on which to run my background processing.
Then just use CreateThread and be done with it. The point of
CWorkerThread is you give it a handle to wait on, and some code to run
once the handle becomes signalled. It's useful when you, say, have
multiple asynchronous file writes or socket communications in flight at
the same time: a single thread can juggle them all.
In the
AddHandle call it says it takes a waitable handle as the first
parameter. Huh ? Where does this handle come from ?
From a number of APIs that create waitable handles, of course. The
documentation on WaitForSingleObject has an exhaustive list.
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'm not sure I understand the question, but see
CWorkerThread::GetThreadHandle.
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.
Then I guess CWorkerThread is not well suited for your purposes.
Obviously, you have already read the documentation, and discovered this
fact. Why then do you insist on using this class?
I
thought that if I program with ATL I should use this neat ATL
functionality.
I don't quite understand. In what sense is this class "neat" when it
plainly doesn't meet your requirements? If you needed to drive a screw,
whould you choose a shiny new hammer over an old battered screwdriver?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925