HarishMinu
asked on
Synchronization between instances of same processes using CreateEvent
Hello experts
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)
{
while (WaitForSingleObject(hEven t,INFINITE )==WAIT_OB JECT_0)
{
Sleep(0);
}
SetEvent (hEvent);
}
else
SetEvent (hEvent );
//in the ending of application.
ResetEvent (hEvent);
Please advise
Thanks in advance
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)
{
while (WaitForSingleObject(hEven
{
Sleep(0);
}
SetEvent (hEvent);
}
else
SetEvent (hEvent );
//in the ending of application.
ResetEvent (hEvent);
Please advise
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.