I've written a service in c# that starts different other (child)processes which run in background. How can I close a process in a graceful way? Process.kill()
is not an option, and Process.CloseMainWindow()
does not work because the child process has no visible window (and shouldn't have any) .
Tanks for your help.
You can use WMI to do this(if that is an option). Look at the examples below: http://www.codeproject.com/KB/cs/EverythingInWmi02.aspx
If you control that other process you can use WCF to communicate between processes, child process should check and ask service if is time to end process and then child process can do close and do needed cleanup. Here is a clean and simple example
http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.