Lets say I have a Windows application named app.exe
, written in C# (Windows Forms), running unattended under any Windows OS (XP to 8).
I would like to monitor the status of the app:
My idea is to set up a scheduled task in Windows (using the Task Scheduler) to run a Windows Console application, monitor.exe
, every 15 minutes.
The monitor app will send an email with the status of app.exe
.
What I have not been able to figure out:
app.exe
is still running?app.exe
from monitor.exe
?One idea was to set up a timer in app.exe
which will write the internal status out to a file, and have monitor.exe
read and evaluate that file every 15 minutes. But that does not appear very elegant to me (however it would work).
Do you have a better, best practise, approach?
Here's a more complicated solution, which you could add a monitor layer and a service layer in app.exe
. The monitor layer is responsible for collecting internal variables status, and the service layer is responsible for providing internal status to whom issuing a GetStatus
request.
Whenever monitor.exe
is executed, it issues a GetStatus
service request to app.exe
, and get the response of what is going on from inside of app.exe
.
The disadvantage is that you must create a connection between app.exe
and monitor.exe
, and the latter must know the service port of all app.exe which deployed on the local machine.