- ccomthread_src.zip
- LegacyCOMObject1
- Shared
- SimpleCOMObject1
- SimpleCOMObject2
- Test Programs
- VBTest
- VCTests
- DemonstrateDefaultSTA
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
- VCTest02
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest02.dsp
- VCTest02.dsw
- DemonstrateExeServerSTA
- Client
- VCTest01
- Implementation
- ExeServerImpl
- Interface
- ExeServerInterfaces
- DemonstrateLegacySTA
- VCTest01
- LegacyCOMObject1.tlh
- LegacyCOMObject1.tli
- main.cpp
- VCTest01.dsp
- VCTest01.dsw
- VCTest02
- DemonstrateNoMessageLoop
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
- DemonstrateSTA
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
|
// ComThread.cpp
#include "ComThread.h"
DWORD ThreadMsgWaitForSingleObject (HANDLE hHandle, DWORD dwMilliseconds)
{
HANDLE dwChangeHandles[1] = { hHandle };
DWORD dwWaitStatus = 0;
DWORD dwRet = 0;
bool bContinueLoop = true;
// Msg Loop while waiting for thread to exit.
while (bContinueLoop)
{
// Wait for notification.
dwWaitStatus = ::MsgWaitForMultipleObjectsEx
(
(DWORD)1, // number of handles in array
dwChangeHandles, // object-handle array
(DWORD)dwMilliseconds, // time-out interval
(DWORD)(QS_ALLINPUT | QS_ALLPOSTMESSAGE), // input-event type
(DWORD)(MWMO_INPUTAVAILABLE) // wait options
);
switch (dwWaitStatus)
{
// First wait (thread exit) object has been signalled.
case WAIT_OBJECT_0 :
{
dwRet = dwWaitStatus;
// Flag to indicate stop loop.
bContinueLoop = false;
break;
}
// Windows message has arrived.
case WAIT_OBJECT_0 + 1:
{
MSG msg;
// Dispatch all windows messages in queue.
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage (&msg);
DispatchMessage(&msg);
}
break;
}
default:
{
break;
}
}
}
return dwRet;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Lim Bio Liong is a Specialist at a leading Software House in Singapore.
Bio has been in software development for over 10 years. He specialises in C/C++ programming and Windows software development.
Bio has also done device-driver development and enjoys low-level programming. Bio has recently picked up C# programming and has been researching in this area.