Running processes at different times stops events from working - C

Posted by Jamie Keeling on Stack Overflow See other posts from Stack Overflow or by Jamie Keeling
Published on 2010-04-28T15:54:10Z Indexed on 2010/04/28 16:53 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

Hello,

This is a question which follows on from my previously answered question here

At first I assumed I had a problem with the way I was creating my events due to the handles for OpenEvent returning NULL, I have managed to find the real cause however I am not sure how to go about it.

Basically I use Visual Studio to launch both Process A and B at the same time, in the past my OpenEvent handle wouldn't work due to Process A looking for the address of the event a fraction of a second before Process B had time to make it.

My solution was to simply allow Process B to run before Process A, fixing the error.

The problem I have now is that Process B now reads events from Process A and as you expect it too returns a null handle when trying to open the events from Process A.

I am creating the events in WM_CREATE message of both processes, furthermore I also create a thread at the same time to open/read/act upon the events.

It seems if I run them at the same time they don't get chance to see each other, alternatively if I run one before the other one of them misses out and can't open a Handle.

Can anyone suggest a solution?

Thanks.

© Stack Overflow or respective owner

Related posts about winapi

Related posts about c