I am trying to communicate between two different processes to tell each one when the other is closing so they both close at the same time.
In this example process a tells process b when it has closed, in the same way process b tells process a when it has closed.

I have set up events but even though they are both set to unsignalled when I create them and even if I use the ResetEvent(); command, they both appear as signalled and close the application as soon as it has opened them.

Has anybody got any idea how to do this? I've been racking my brains on this for over a week now and I'm struggling to work out what I need to do.

I have already asked this type of question on another website but the solution I was given does not seem to work (The website forced me to accept it).

How to send Event signal through Processes - C - Stack Overflow

Thanks for the help!

Progress so far:

Process A:

Code:
DWORD WINAPI ThreadFunc(LPVOID passedHandle)
{
	while(TRUE)
	{
		WaitForSingleObject(hConsumerClosedEvent,INFINITE);

		switch (dwCloseResult) 
		{
			// State of object is signalled
		case WAIT_OBJECT_0: 
			//Consumer has closed, exit program.
			CloseHandle(hDiceRoll);
			CloseHandle(hConsumerClosedEvent);
			CloseHandle(hCreateEventThread);
			ExitProcess(1);
			break;
		default: 
			return;
		}
}
}

Creating the event:

Code:
hConsumerClosedEvent = CreateEvent( 
				NULL,               // default security attributes
				TRUE,               // manual-reset event
				FALSE,              // initial state is nonsignaled
				TEXT("Global\\ConsumerClosedEvent")  // object name
				);

Process B:

Code:
DWORD WINAPI ThreadFunc(LPVOID passedHandle)
{
	while(TRUE)
	{
		WaitForSingleObject(hConsumerClosedEvent,INFINITE);

		switch (dwCloseResult) 
		{
			// State of object is signalled
		case WAIT_OBJECT_0: 
			//Consumer has closed, exit program.
			CloseHandle(hDiceRoll);
			CloseHandle(hConsumerClosedEvent);
			CloseHandle(hCreateEventThread);
			ExitProcess(1);
			break;
		default: 
			return;
		}
	}
}
Creating the event:

Code:
hConsumerClosedEvent = CreateEvent( 
				NULL,               // default security attributes
				TRUE,               // manual-reset event
				FALSE,              // initial state is nonsignaled
				TEXT("Global\\ConsumerClosedEvent")  // object name
				);