Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CWorkerThread Class
Collapse the table of content
Expand the table of content

CWorkerThread Class

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.

Important note Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

template < 
class ThreadTraits= DefaultThreadTraits 
> 
class CWorkerThread

ThreadTraits

The class providing the thread creation function, such as CRTThreadTraits or Win32ThreadTraits.

Name

Description

WorkerClientEntry

Name

Description

CWorkerThread::CWorkerThread

The constructor for the worker thread.

CWorkerThread::~CWorkerThread

The destructor for the worker thread.

Name

Description

CWorkerThread::AddHandle

Call this method to add a waitable object's handle to the list maintained by the worker thread.

CWorkerThread::AddTimer

Call this method to add a periodic waitable timer to the list maintained by the worker thread.

CWorkerThread::GetThreadHandle

Call this method to get the thread handle of the worker thread.

CWorkerThread::GetThreadId

Call this method to get the thread ID of the worker thread.

CWorkerThread::Initialize

Call this method to initialize the worker thread.

CWorkerThread::RemoveHandle

Call this method to remove a handle from the list of waitable objects.

CWorkerThread::Shutdown

Call this method to shut down the worker thread.

To use CWorkerThread

  1. Create an instance of this class.

  2. Call CWorkerThread::Initialize.

  3. Call CWorkerThread::AddHandle with the handle of a kernel object and a pointer to an implementation of IWorkerThreadClient.

    – or –

    Call CWorkerThread::AddTimer with a pointer to an implementation of IWorkerThreadClient.

  4. Implement IWorkerThreadClient::Execute to take some action when the handle or timer is signaled.

  5. To remove an object from the list of waitable objects, call CWorkerThread::RemoveHandle.

  6. To terminate the thread, call CWorkerThread::Shutdown.

Header: atlutil.h

Show:
© 2015 Microsoft