Search code examples
c#.netservice

Watchdog application dilemma


I am developing a Watchdog App for a digital signage computer (think store kiosks with screens playing ads). Basically there is a main application that handles all the content processing/playback, and I am making a second application that will check on the first one and restart it if it crashed.

I am making this in C# and I found myself stuck between 2 options.

  1. Develop a normal console app that will run via Task Scheduler and have it create a timer, that will call a function that does the necessary checks and actions. Meanwhile, the main part of the application will have to enter a infinite while loop of Sleep calls so that the application does not exit.

  2. When I researched if I can avoid the while (true){ Thread.Sleep(1000); } part, most responses I found recommended to write a service application instead.

    And after attempting to do a similar thing with a Windows Service, I found that it doesn't have direct access to the user session where I need to launch the application. Therefore, it starts the process but fails to show any GUI on the screen.

So if the Windows Services can't launch a GUI app and a console application shouldn't be running a timer while sleeping, is there an elegant solution to this?


Solution

  • You can develop a normal console app that makes just the necessary checks, and let the Task Scheduler to run it every 1 minutes (that is the minimun time available)