I have a Windows service(C#), that sprawns few child native processes (C++).
I’d like to gently kill those processes once in a while. (gently = let the procs to finalize its work before going down).
I tried to use the SetConsoleCtrlHandler() routine to register the child procs to console events and to call the CloseMainWindow() from the C# code to raise the ‘close console’ events.
This didn’t work for me. Mainly because the child processes are not console applications.
Does anyone knows what other methods can be used in order to fulfill this requirement?
Kernel event objects come to mind: your ‘manager’ raises a named event. Your child processes should check the state of this event at least once in a while (or have a thread that continuously checks it).