This class is only available in the RT environment. It has been derived from CIThread to ease the creation of a thread that waits for incoming messages at a message queue. It must be used to derive an application specific message queue thread class, or it can be used directly to control a thread object. See also CIThread. In contrast to the C implementation of message queues, the C++ class handles short and long messages by its own and just delivers the data in the OnReceive function.
Constructor
Destructor
Create
DoForever
ExitInstance
OnReceive
The following member variable is only available to the members of the class and its derived classes:
CIMessageQueue m_MQu;
See CIThread::Constructor.
See CIThread::Destructor.
If the object is already attached, it is first detached. Then this call creates a new active RT thread object and attaches it to the object.
DWORD CIMessageQueueThread::Create( char * pszName, char * pszMbx, DWORD dwQueueSize, DWORD dwMsgThreshold, BYTE byPrio, DWORD dwStack, BOOLEAN bGo );
pszName
pszMbx
dwQueueSize
dwMsgThreshold
byPrio
dwStack
bGo
The new thread creates the message queue and catalogs it. The result is a status indicating success or failure:
E_OK
E_MEM
E_LIMIT
byPrio
contains a bad value, or the object directory is full.
E_SLOT
E_PARAM
dwStack
contains a value of less than 2048, or either name is too long or is improperly formatted.
E_CONTEXT
For details on the code executed by the new thread, see CIThreadCreate.
See CIThread::DoForever. CIMessageQueueThread::DoForever is called by the framework and should never be called explicitly. CIMessageQueueThread::DoForever waits for a message at the data mailbox (no timeout), calls the OnReceive member (only after successful receive) and returns a boolean status (TRUE for success, FALSE for failure). When overruling this call, do not include a call to the default call.
See CIThread::ExitInstance. CIMessageQueueThread::ExitInstance is called by the framework before terminating the thread and should never be called explicitly. CIMessageQueueThread::ExitInstance detaches the data mailbox object and then returns 0.
CIMessageQueueThread::OnReceive is called by the framework when a message has been received successfully and should never be called explicitly. CIMessageQueueThread::OnReceive just returns TRUE. When overruling this call, there is no need to call the default call.
BOOLEAN CIMessageQueueThread::OnReceive( BYTE * pBuffer, WORD wLen);
The call gets two parameters: pBuffer points to a buffer containing the message, wLen contains the number of bytes received. The result must be TRUE to let the thread continue, FALSE to terminate the thread.