ReactOS  0.4.14-dev-1007-g90d795b
event.c File Reference
#include <windows.h>
#include <stdio.h>
Include dependency graph for event.c:

Go to the source code of this file.

Functions

DWORD WINAPI thread (LPVOID crap)
 
int main (void)
 

Variables

HANDLE events [2]
 

Function Documentation

◆ main()

int main ( void  )

Definition at line 14 of file event.c.

15 {
16  DWORD id, Status;
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 );
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" ) );
32  return 0;
33 }
#define CreateEvent
Definition: winbase.h:3582
#define TRUE
Definition: types.h:120
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
DWORD WINAPI thread(LPVOID crap)
Definition: event.c:6
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_TIMEOUT
Definition: dderror.h:14
Status
Definition: gdiplustypes.h:24
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
HANDLE events[2]
Definition: event.c:4
GLenum GLuint id
Definition: glext.h:5579
#define INFINITE
Definition: serial.h:102
#define printf
Definition: config.h:203

◆ thread()

DWORD WINAPI thread ( LPVOID  crap)

Definition at line 6 of file event.c.

7 {
8  SetEvent( events[0] );
9  if( crap )
10  SetEvent( events[1] );
11  return 1;
12 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
HANDLE events[2]
Definition: event.c:4

Referenced by main().

Variable Documentation

◆ events