Here is the situation: I have to create a program that will inject another stream of process output into the text box. This alone will not cause too many problems. However, it does matter that I have to start 5 instances of this console application and redirect the output to 5 text fields, as well as be able to kill any of these processes at any time. As far as I know, the best way to do this is asynchronously. But the problem here is the killing processes that are created on different threads. How to kill him without having access to him, because he does not exist in the area where I have to kill him. My best guess is to get its PID on Process.Start() , so I can kill it, so ...
Is it possible to fire any event from a process using the Process.kill() command? And if not - is there a way to kill the process at about the same time interval as Process.kill() , which fires some kind of event?
Or maybe someone can offer me other approaches or best practices regarding how these problems are usually resolved?
EDIT: The reason I execute all processes on different threads is because I use Thread.Sleep() for some of them, if there is and enter a parameter that tells me that the process should be killed in x seconds.
source share