how to finde out in C# that a prossess "exe" is allready runningor not ?

S

Saleh Matani

how to finde out in C# that a prossess "exe" is allready running or not ?
and how to make programm wait 1 sec between checks?

thank you

Saleh Matani
 
R

raj

i used the win32 api calls findwinow, etc in my last app
i am sure there are better ways
 
R

raj

sorry didn t completely answer your question

i used FindWindow api calls for my last app, it wored well.

I would use a timer with interval of 1000 and on timer tick event call the
findwindow api.
 
W

Willy Denoyette [MVP]

Saleh Matani said:
how to finde out in C# that a prossess "exe" is allready running or not ?
and how to make programm wait 1 sec between checks?

thank you

Saleh Matani

To find an instance of a running process, you can use the static
"GetProcessesByName" method of the Process class.
You can set-up a timer using the various Timer classes in the framework,
check System.Timers, System.Threading.Timers or the
System.Windows.Forms.Timer classes.
Question is, why exactly do you need to know if an exe is already running?

Willy.
 
M

milk-jam

try the following line of code worked for me

Process[] arrProcess;
arrProcess=Process.GetProcesses(/* Conputer Name*/);

foreach (Process p in arrProcess)
{
if (p.ProcessName=="/*prossess "exe" name*/ ")
{
// Log the Event, here u can get when the process
is started or closed
}
}
 
S

Saleh Matani

thank you :)

milk-jam said:
try the following line of code worked for me

Process[] arrProcess;
arrProcess=Process.GetProcesses(/* Conputer Name*/);

foreach (Process p in arrProcess)
{
if (p.ProcessName=="/*prossess "exe" name*/ ")
{
// Log the Event, here u can get when the process
is started or closed
}
}

how to finde out in C# that a prossess "exe" is allready running or not ?
and how to make programm wait 1 sec between checks?

thank you

Saleh Matani
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top