6 DWORD WINAPI
thread( LPVOID crap
)
10 SetEvent( events
[1] );
17 printf( "Creating events\n" );
18 events
[0] = CreateEvent( 0, TRUE
, FALSE
, 0 );
19 events
[1] = CreateEvent( 0, TRUE
, FALSE
, 0 );
20 printf( "Created events\n" );
21 CreateThread( 0, 0, thread
, 0, 0, &id
);
22 printf( "WaitForSingleObject %s\n", ( WaitForSingleObject( events
[0], INFINITE
) == WAIT_OBJECT_0
? "worked" : "failed" ) );
23 ResetEvent( events
[0] );
24 CreateThread( 0, 0, thread
, 0, 0, &id
);
25 printf( "WaitForMultipleObjects with waitall = FALSE %s\n", ( WaitForMultipleObjects( 2, events
, FALSE
, INFINITE
) == WAIT_OBJECT_0
? "worked" : "failed" ) );
26 ResetEvent( events
[0] );
27 CreateThread( 0, 0, thread
, (void *)1, 0, &id
);
28 Status
= WaitForMultipleObjects( 2, events
, TRUE
, INFINITE
);
29 printf( "WaitForMultipleObjects with waitall = TRUE %s\n", ( Status
== WAIT_OBJECT_0
|| Status
== WAIT_OBJECT_0
+ 1 ? "worked" : "failed" ) );
30 ResetEvent( events
[0] );
31 printf( "WaitForSingleObject with timeout %s\n", ( WaitForSingleObject( events
[0], 100 ) == WAIT_TIMEOUT
? "worked" : "failed" ) );