Creating a Service that monitors the processes on the OS

G

Guest

I have a multithreading application that opens an app in the background from
a service and runs it. For some reason it will not close this instance of the
app when it is done using it. This is a 3rd party app. By the end of the day
I have so many instances open it will not open another one and the app
becomes useless. I then have to manually open the task manager and close the
inactive instances of this app.

Is it possible to create a service that monitors the processes on the OS and
close the inactive instances of this app?

-Chris
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


You better contact the third party provider and tell them about the problem.
What you want to do is not the best solution, you have no idea what the app
does or what resources it use.

Anyway, what you can do is get a list of Processes using
System.Diagnostics.Process.GetProcesses and just kill them by using Kill
 
G

Guest

Great, I am sort of new the .Net world. Any suggestions on how to get
started. What objects do I need to grab and how would I grab them?

Thanks Again,

-Chris
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Inmy post you will find what you need, the Process class, the GetProcessed
method and the most important method of all the Kill method :)

just use them wisely ;)
 
G

Guest

Thank you Ignacio

-Chris


Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Inmy post you will find what you need, the Process class, the GetProcessed
method and the most important method of all the Kill method :)

just use them wisely ;)
 
W

Willy Denoyette [MVP]

Chris said:
I have a multithreading application that opens an app in the background
from
a service and runs it. For some reason it will not close this instance of
the
app when it is done using it. This is a 3rd party app. By the end of the
day
I have so many instances open it will not open another one and the app
becomes useless. I then have to manually open the task manager and close
the
inactive instances of this app.

Is it possible to create a service that monitors the processes on the OS
and
close the inactive instances of this app?

-Chris


I'm not clear on what you mean by "it will not close this instance of the
app when it is done using it.", who is *it*, who's supposed to *close* the
application and what exactly do you mean with *close*.
What kind of application is this that you start from a Windows service?

Willy.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Willy Denoyette said:
I'm not clear on what you mean by "it will not close this instance of the
app when it is done using it.", who is *it*, who's supposed to *close* the
application and what exactly do you mean with *close*.
What kind of application is this that you start from a Windows service?


From his post I think he just want to kill some process. How he decide which
process is "idle" I have no idea
 
W

Willy Denoyette [MVP]

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.



From his post I think he just want to kill some process. How he decide
which process is "idle" I have no idea


The problem IMO, is that the OP starts an application that was not really
designed to be started from a Service. An application that is started from a
Service needs to be as robust as a Service itself, must not assume to run in
an interactive session and must be able to recover from failures or at least
to signal failures back to the process that started the application. Anyway,
killing a process is something you do as a last resort.

Willy.
 

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