views:

25

answers:

1

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.

+1  A: 

Just replace OpenEvent with CreateEvent. CreateEvent will open an Event instead of creating a new one it finds an existing event with the name passed to CreateEvent.

torak
Hmm, it sounds a bit trivial. I'll give it a go and see how it pans out, Hopefully it shouldn't take too long to implement.
Jamie Keeling
I decided to make one process open the other one, checking it's already available before looking for the events available. Thank you for the help.
Jamie Keeling