?? cthread.htm
字號:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>CThread Help</TITLE>
<META NAME="Template" CONTENT="C:\Program Files\Microsoft Office\Office\html.dot">
</HEAD>
<BODY LINK="#0000ff" VLINK="#800080">
<H1><A NAME="__aaaContents">Contents</A></H1>
<P>To display a list of topics by category, click any of the contents entries below. To display an alphabetical list of topics, choose the Index button.</P>
<H3>C/C++ Elements</H3>
<P><A HREF="#_aaaClasses_and_Class_Members">Classes and Class Members</A></P>
<P><A HREF="#_aaaStructures_and_Enums">Structures and Enums</A></P>
<H3>Other</H3>
<P><A HREF="#_aaaOverviews">Overviews</A></P>
<P><A HREF="#_aaaModules">Modules</A></P>
<P>Help file built: 08/30/99</P>
<P><A HREF="#_aaaAbout_Autoduck">About Autoduck</A></P>
<P><HR></P>
<H1><A NAME="_aaaAbout_Autoduck">About Autoduck</A></H1>
<P>The sources for this Help file were generated by Autoduck, the source code documentation tool that generates Print or Help files from tagged comments in C, C++, Assembly, and Basic source files.</P>
<P>For more information, contact Eric Artzt (erica@microsoft.com).</P>
<P><HR></P>
<H1><A NAME="_aaaClasses_and_Class_Members">Classes and Class Members</A></H1>
<UL>
<LI><A HREF="#CThread">CThread</A> Class </LI>
<LI><A HREF="#CThreadException">CThreadException</A> Class</LI></UL>
<P><HR></P>
<H1><A NAME="_aaaModules">Modules</A></H1>
<UL>
<LI><A HREF="#CThread_cpp">CThread.cpp</A> </LI>
<LI><A HREF="#CThread_h">CThread.h</A> </LI></UL>
<P><HR></P>
<H1><A NAME="_aaaOverviews">Overviews</A></H1>
<UL>
<LI><A HREF="#CThread_Class">CThread Class</A> </LI>
<LI><A HREF="#CThreadException_Class">CThreadException Class</A> </LI>
<LI><A HREF="#License_Conditions">License Conditions</A> </LI></UL>
<P><HR></P>
<H1><A NAME="_aaaStructures_and_Enums">Structures and Enums</A></H1>
<UL>
<LI><A HREF="#CThread_Activity_Status_Predefined_Values">CThread Activity Status Predefined Values</A> </LI>
<LI><A HREF="#CThread_General_Predefined_Values">CThread General Predefined Values</A> </LI>
<LI><A HREF="#CThread_Predefined_Commands">CThread Predefined Commands</A> </LI>
<LI><A HREF="#CThreadException_Predefined_Types">CThreadException Predefined Types</A> </LI></UL>
<P><HR></P>
<P><A NAME="CThread_Class"></P>
<H1>CThread Class</H1>
<P></A>The base MFC CObject-derived class that encapsulates WINDOWS Worker Thread abilities. <BR>
CThread class offers many features that are not implemented or supported by WINDOWS System. It allows to build up the full-fledged OOP Class hierarchy, supports several levels of safe Thread Synchronization as well as the Thread Notification. <BR>
<BR>
Detailed information how do CThreads work, how should be managed or handled can be found in the 'Developer.doc' documentation in '\\Doc' subdirectory of the main installation directory.</P>
<P><HR></P>
<P><A NAME="CThreadException_Class"></P>
<H1>CThreadException Class</H1>
<P></A>The base CException-derived class used in CThread-derived classes.</P>
<P><HR></P>
<P><A NAME="License_Conditions"></P>
<H1>License Conditions</H1>
<P></A>This software is a freeware and may be freely used or distributed without restriction.</P>
<P><HR></P>
<P><A NAME="CThread_cpp"></P>
<H1>CThread.cpp</H1>
<H3></A>Description</H3>
<P>PROJECT		: CThread Class <BR>
SUBSYSTEM	: CThread Base Class <BR>
AUTHOR		: Dominik Filipp, © 1999, Slovakia, Europe</P>
<P><BR>
DESCRIPTION: <BR>
Abstract Base CThread Class implementation file.</P>
<P><HR></P>
<P><A NAME="CThread_h"></P>
<H1>CThread.h</H1>
<H3></A>Description</H3>
<P>PROJECT		: CThread Class <BR>
SUBSYSTEM	: CThread Base Class <BR>
AUTHOR		: Dominik Filipp, © 1999, Slovakia, Europe</P>
<P><BR>
DESCRIPTION: <BR>
Abstract Base CThread Class header file.</P>
<P><HR></P>
<P><A NAME="CThread"></P>
<H1>CThread class</H1>
<P></A>CThread <B>class CThread: public CObject</P>
</B><P>CThread Class Members</P>
<H3>Class Members</H3>
<B><P><BR>
Public Members:</B> </P>
<DL>
<DT><A HREF="#CThread__CThread">CThread</A><B>(void* pOwnerObject = NULL, LPARAM lParam = 0L)</B> </DT>
<DD>CThread Constructor</DD>
<B><DT>virtual</B> <A HREF="#CThread__.7eCThread">~CThread</A><B>()</B> </DT>
<DD>CThread Destructor</DD>
<B><DT>SECURITY_ATTRIBUTES</B> <A HREF="#CThread__GetAttributes">GetAttributes</A><B>() const</B> </DT>
<DD>Get Thread Attributes</DD>
<B><DT>DWORD</B> <A HREF="#CThread__GetStackSize">GetStackSize</A><B>() const</B> </DT>
<DD>Get Thread Stack Size</DD>
<B><DT>HANDLE</B> <A HREF="#CThread__GetHandle">GetHandle</A><B>() const</B> </DT>
<DD>Get Thread Handle</DD>
<B><DT>DWORD</B> <A HREF="#CThread__GetID">GetID</A><B>() const</B> </DT>
<DD>Get Thread ID</DD>
<B><DT>DWORD</B> <A HREF="#CThread__GetExitCode">GetExitCode</A><B>() const</B> </DT>
<DD>Get Thread Exit Code</DD>
<B><DT>int</B> <A HREF="#CThread__GetActivityStatus">GetActivityStatus</A><B>() const</B> </DT>
<DD>Get Thread Activity Status</DD>
<B><DT>int</B> <A HREF="#CThread__GetPriority">GetPriority</A><B>() const</B> </DT>
<DD>Get WINDOWS Thread Priority</DD>
<B><DT>BOOL</B> <A HREF="#CThread__IsAlive">IsAlive</A><B>()</B> </DT>
<DD>Check if Thread is Alive</DD>
<B><DT>void</B> <A HREF="#CThread__Start">Start</A><B>()</B> </DT>
<DD>Start Thread</DD>
<B><DT>void</B> <A HREF="#CThread__Run">Run</A><B>()</B> </DT>
<DD>Fire Run Command</DD>
<B><DT>void</B> <A HREF="#CThread__Pause">Pause</A><B>()</B> </DT>
<DD>Fire Pause Command</DD>
<B><DT>void</B> <A HREF="#CThread__Continue">Continue</A><B>()</B> </DT>
<DD>Fire Continue Command</DD>
<B><DT>void</B> <A HREF="#CThread__Reset">Reset</A><B>()</B> </DT>
<DD>Fire Reset Command</DD>
<B><DT>BOOL</B> <A HREF="#CThread__Stop">Stop</A><B>(DWORD& dwExitCode, DWORD dwTimeout = CThread::DW_INFINITE)</B> </DT>
<DD>Fire Stop Command</DD>
<B><DT>void</B> <A HREF="#CThread__Kill">Kill</A><B>(DWORD dwExitCode = CThread::DW_OK, BOOL bCloseAnyway = FALSE)</B> </DT>
<DD>Kill Thread</DD>
<B><DT>void</B> <A HREF="#CThread__PostCommand">PostCommand</A><B>(int nCommand)</B> </DT>
<DD>Post Command to Thread</DD>
<B><DT>void</B> <A HREF="#CThread__ResetCommands">ResetCommands</A><B>()</B> </DT>
<DD>Cancel All Notification Commands</DD>
<B><DT>void</B> <A HREF="#CThread__SetOwnerParams">SetOwnerParams</A><B>(void* pOwnerObject, LPARAM lParam = 0L)</B> </DT>
<DD>Set Owner Object Parameters</DD>
<B><DT>void</B> <A HREF="#CThread__GetOwnerParams">GetOwnerParams</A><B>(void*& pOwnerObject, LPARAM& lParam) const</B> </DT>
<DD>Get Owner Object Parameters</DD>
<B><DT>void</B> <A HREF="#CThread__SetAttributes">SetAttributes</A><B>(LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL)</B> </DT>
<DD>Set Thread Attributes</DD>
<B><DT>void</B> <A HREF="#CThread__SetStackSize">SetStackSize</A><B>(DWORD dwStackSize = 0)</B> </DT>
<DD>Set Thread Stack Size</DD>
<B><DT>BOOL</B> <A HREF="#CThread__SetPriority">SetPriority</A><B>(int nPriority = THREAD_PRIORITY_NORMAL)</B> </DT>
<DD>Set WINDOWS Thread Priority</DD>
<B><DT>BOOL</B> <A HREF="#CThread__WaitForActivityStatus">WaitForActivityStatus</A><B>(int nActivityStatus, DWORD dwTimeout = CThread::DW_INFINITE) const</B> </DT>
<DD>Wait For the Desired CThread Activity Status</DD>
<B><DT>static void</B> <A HREF="#CThread__OpenProcessLocking">OpenProcessLocking</A><B>()</B> </DT>
<DD>Open Process Synchronization</DD>
<B><DT>static void</B> <A HREF="#CThread__CloseProcessLocking">CloseProcessLocking</A><B>()</B> </DT>
<DD>Close Process Synchronization</DD>
<B><DT>static void</B> <A HREF="#CThread__ProcessLock">ProcessLock</A><B>()</B> </DT>
<DD>Lock Critical Code in Process Synchronization Mode</DD>
<B><DT>static void</B> <A HREF="#CThread__ProcessUnlock">ProcessUnlock</A><B>()</B> </DT>
<DD>Unlock Critical Code in Process Synchronization Mode</DD>
</DL>
<H3>Class Members</H3>
<B><P><BR>
Protected Members:</B> </P>
<B><DL>
<DT>void</B> <A HREF="#CThread__SetActivityStatus">SetActivityStatus</A><B>(int nActivityStatus)</B> </DT>
<DD>Set Thread Activity Status</DD>
<B><DT>void</B> <A HREF="#CThread__Lock">Lock</A><B>()</B> </DT>
<DD>Lock Critical Code in Thread-Handler-Oriented Synchronization Mode</DD>
<B><DT>void</B> <A HREF="#CThread__Unlock">Unlock</A><B>()</B> </DT>
<DD>Unlock Critical Code in Thread-Handler-Oriented Synchronization Mode</DD>
<B><DT>void</B> <A HREF="#CThread__WaitForNotification">WaitForNotification</A><B>(int& nIncomingCommand, DWORD dwDefaultTimeout = CThread::DW_INFINITE)</B> </DT>
<DD>Wait for Incoming Commands</DD>
<B><DT>BOOL</B> <A HREF="#CThread__HandleCommandImmediately">HandleCommandImmediately</A><B>(int nCommand)</B> </DT>
<DD>Handle Command Immediately Bypassing Other Pending Commands</DD>
<B><DT>virtual DWORD</B> <A HREF="#CThread__ThreadHandler">ThreadHandler</A><B>()</B> </DT>
<DD>Main Thread Task Handler (Abstract Declaration)</DD>
<B><DT>virtual void</B> <A HREF="#CThread__OnKill">OnKill</A><B>()</B> </DT>
<DD>Make Specific Unallocations After The Thread Has Been Killed</DD>
</DL>
<P><HR></P>
<P><A NAME="CThread__CloseProcessLocking"></P>
<H1>CThread::CloseProcessLocking</H1>
<B><P></A>static void</B> <B>CThread::CloseProcessLocking(void) </P>
</B><P>Static method that closes the process synchronization that was previously opened by <B>OpenProcessLocking</B>. <BR>
The synchronization itself is accomplished by calling <B>ProcessLock</B> and <B>ProcessUnlock</B> methods between which is the critical code that is to be executed process-exclusively. <BR>
<BR>
As a static method may be used wherever in the code without constructing any CThread object.</P>
<H3>See Also</H3>
<B><P>OpenProcessLocking</B> <BR>
<B>ProcessLock</B> <BR>
<B>ProcessUnlock</P>
</B><P>Back to <A HREF="#CThread">CThread</A></P>
<P><HR></P>
<P><A NAME="CThread__Continue"></P>
<H1>CThread::Continue</H1>
<B><P></A>void</B> <B>CThread::Continue(void) </P>
</B><P>	<B>throws CThreadException</B> of type: <BR>
	CThreadException::CANNOT_SIGNAL_NOTIFICATION_OBJECT <BR>
<BR>
Fires CThread::CMD_CONTINUE Command and notifies CThread object. Used in the owner thread. This method is valid only if CThread-derived class supports Thread Notification and CThread thread has been successfully started. Otherwise it has no any effect. <BR>
To use the method properly the <B>ThreadHandler</B> method must be able to handle CThread::CMD_CONTINUE Command as well as implement the specific task corresponding to this command. <BR>
This method returns immediately after the command has been fired. The owner thread may, however, wait for completion of the corresponding task by using the paradigm described in the <B>WaitForActivityStatus</B> method. <BR>
<BR>
This method is a helper method simplifying the semantic control of Notificable CThread threads acting in a 'scheduler' or 'service' - like manner. It's up to the developer's responsibility how to interpret and implement (or refuse at all) this method. <BR>
<BR>
For more information see 'Developer.doc' documentation.</P>
<H3>See Also</H3>
<B><P>PostCommand</B> <BR>
<B>WaitForActivityStatus</B> <BR>
<A HREF="#CThread">CThread Predefined Commands</A></P>
<P>Back to <A HREF="#CThread">CThread</A></P>
<P><HR></P>
<P><A NAME="CThread__CThread"></P>
<H1>CThread::CThread</H1>
<B><P></A>CThread::CThread(void*</B> <I>pOwnerObject</I> <B>= NULL, LPARAM</B> <I>lParam</I> <B>= 0</B> <B>) </P>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -