Question

I am currently using an EventWaitHandle to trigger a clean shutdown of a native process that doesnt have a window from a Windows Forms app. When I have multiple of these processes running at the same time, setting the event will stop all of them. Is there any way to send an event to a single selected process? I retain a Process variable for each of them.

EventWaitHandle Event = new EventWaitHandle(false, EventResetMode.ManualReset, "EventName");
Event.Set();

No correct solution

OTHER TIPS

It sounds more like you want a named event handle per process.

You could use Process.Id to get a unique ID for each process, and use it to generate a unique string for each process.

Because the process ID is global, it makes it safe to assume that the ID can be used by both processes correctly.

You can then append this number onto some string like "MyProcessEvent" to give, say, "MyProcessEvent6345615". Then use that string to open the named EventWaitHandle in both processes.

Then your controller process can signal any of the processes it started using that name.

(A process finds its own ID via Process.GetCurrentProcess()).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top