Issue with OpenEvent

  • Thread starter Thread starter Harsha_MR
  • Start date Start date
H

Harsha_MR

Guest
I 'm having 2 processes, one for creating Event and other for getting the event name.

While using OpenEvent, I don't get the Event Handler properly. Sometime i get and sometime it's NULL. I do see the Event created properly with the valid handle. I could print the same name getting passed to OpenEvent call also.

what could go wrong..?


//Process 1 - OpenEvent process
static HANDLE hBinEvent[100];
void GetEventName(int a_Process_number, int eventcount)
{
char h_str[2] = { 0 };
char h_EventName[20] = "Process_";
int stringlength;
stringlength = strlen(h_EventName);
itoa(a_Process_number, h_str, 10);
strcat(h_EventName, h_str);
h_EventName[stringlength + 1] = '\0';
do {
hBinEvent[eventcount] = OpenEvent(SYNCHRONIZE, FALSE, LPCWSTR(h_EventName));
printf((h_EventName)); \\ name gets printed properly - 'Process_0' and also for 'Process_1'
} while (NULL == hBinEvent[eventcount]);
}

int main(void)
{
GetEventName(1, 0);
GetEventName(1, 1);
return 0;
}



//Process 2 - CreateEvent process
static HANDLE gBinEvent;
void CreateEventName()
{
char g_str[2] = {0};
char g_EventName[20] = "Process_";
int stringlength;
stringlength = LSL_strlen(g_EventName);
LSL_itoa(a_Process_number, g_str, 10);
LSL_strcat(g_EventName, g_str);
g_EventName[stringlength + 1] = '\0';
do{
gBinEvent = CreateEvent(
NULL,
FALSE,
FALSE,
LPCWSTR(g_EventName)
);
printf((g_EventName)); \\ name gets printed properly - 'Process_0' and also for 'Process_1'
} while (NULL == gBinEvent);
}

int main(void)
{
CreateEventName(0);
CreateEventName(1);
return 0;
}

Continue reading...
 
Back
Top