Windows Process Monitor Design

I am developing a Windows service that supports a list of processes. He can run tasks on them. For example, stop a specific process (in its list), restart a specific process, start a new process and add it to the list, etc.

This Windows service is controlled by the web application through the WCF service - the Windows service starts the WCF service, and the web application connects to this WCF service. The WCF service exports methods such as Restart(int id)and Stop(int id).

I have a few questions:

  • When a process unexpectedly closes (for example, due to an internal error), the service must update the value in some database. Right now, to do this, I just have a thread that checks every 30 seconds whether this process is working or not.

    Is that right to it? Should I use an event Exit?

  • When a service is shut down, for any reason, all the processes that it supports are also shut down. What is the right way to do this?

    I thought just to skip the list and kill all the processes when the service is called OnClose(). The problem is that the event is OnClose()not always triggered. For example, what if the service unexpectedly closes? He will not call OnClose().

  • (, )?

    System.Threading.Tasks. ?

.

.

+5
1

, , , .

  • , , .
  • .
  • "" " ", " " " ".

, .

0

All Articles