Click here to Skip to main content
15,745,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How will i check that my creating process is exist in Windows Task Manager???
Please Help me...

Or if you know the name of the process you can use: Process.GetProcessesByName Method (String)[^].

However, if you have created the process have you created it with for example: Process.Start Method (ProcessStartInfo)[^]. If you have, that method returns the started process which you can use for later investigation/communication etc. So putting the return value to a variable may eliminate the need to find the process.
Share this answer
Sergey Alexandrovich Kryukov 19-Dec-11 19:31pm    
The second paragraph is correct. As I understand, if the child process is created by the current code, the child process status can always be checked up.

As to getting processes by name, who can guarantee that this is no some other process with exact same name?
Wendelius 20-Dec-11 0:29am    
Yep, I know, that's the method returns an array of Processes. Should've mentioned. Thanks for pointing out.
Sergey Alexandrovich Kryukov 19-Dec-11 19:57pm, this problem is simple but not as trivial.
Please see my solution.
Use GetProcesses()

For more details read :[^]
Share this answer
Sergey Alexandrovich Kryukov 19-Dec-11 19:32pm    
Not exactly; please see my comment to the answer by Mika.
The answer by Mika need clarification and improvements. First of all, see my comments to his answer.

As if you only know the process by its name, there is no reliable way to know that the project found among running processes is the one you need.

I assume you are talking about a process you start as a child process of your current process using System.Diagnostics.Project.Start. There are several methods under this name, and all of them allow to check up the status of the process. First of all, you need to get an instance of the Project type in question. There are 5 static methods; and each of them returns this instance, and the only non-static (instance) method is called with the instance created with the constructor, presumably with assigned ProcessInfo. For this method, you should first check up if the start was successful, by its Boolean return value. So, in all cases, you have an instance of the class Process.


Now, you need to check up it's current status. One method to do this is the property ExitCode. You need to assume that the process was successfully started (see above) and you use the same instance of Process. If you get an exit code value, it means that the process is exited. If it is not, you will get an exception. You cannot get the exception NotSupportedException because you know that the process start was successful. When you have the exception InvalidOperationException, it cannot be the case when a handle is invalid, by the reason explained above. So, this exception is the indication that the process is running. Catch this exception while checking ExitCode and you are done.


Alternatively, you can check up the property ExitTime, see[^]. You will need to handle exceptions in the same way as in the method based on ExitCode.

Finally, handle the event Exited to capture the moment of exiting:

myChildProcess.Exited += (sender, eventArgs) => {
    this.ChildIsRunning = false; //for example, you can introduce such flag as your declaring class's field


Share this answer
Wendelius 20-Dec-11 0:30am    
Good clarification, 5'd

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900