/* The following example uses the CreateEvent() function to create two event objects and the CreateThread() function
to create a thread. It then uses the WaitForMultipleObjects() function to wait for the thread to set the state of
one of the objects to signaled using the SetEvent() function. */
// For WinXp as a target, change appropriately
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <stdio.h>
// Global variable
HANDLE ghEvents[2];
// Prototype
DWORD WINAPI ThreadProc( LPVOID );
int wmain(void){
HANDLE hThread;
DWORD i, dwEvent, dwThreadID;
wprintf(L"The current thread ID is: %d\n", GetCurrentThreadId());
// Create two event objects
for (i = 0; i < 2; i++){
ghEvents[i] = CreateEvent(
NU