Synchronization between instances of same processes using CreateEvent
Posted on 2014-03-19
I have a problem when synchronizing the same instances of a process. My application will call from other jobs simultaneously , it instantiate the multiple instances of the application.
I want to create a event in the application and signal it after completion of one instance I will un-signal it, other instances should instances should wait until first completes.
created sample code. but it is in infinite loop.
HANDLE hEvent1 = CreateEvent ( NULL , true , false , L"MyEvent" );
hEvent = OpenEvent ( EVENT_ALL_ACCESS , false, L"MyEvent" );
if(GetLastError () == ERROR_ALREADY_EXISTS)
SetEvent (hEvent );
//in the ending of application.
Thanks in advance