Creating a Service that monitors the processes on the OS

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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 ;)
 
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 ;)
 
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.
 
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
 
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.
 
Back
Top