I have a small, long-running, embedded, NETMF program that stops for unknown reasons (see How do we trouble shoot a long-running NETMF program that stops in production?). As a workaround, I would like it to automatically restart on fail. My sense is that a try-catch block could do this. How? Is this even possible? Is there a better approach?
public class Program
{
private static Timer timer;
public static void Main()
{
Program p = new Program();
Program.timer =
new Timer(this.TimerCallback_DoSomething, new object(), 0, 1000);
Thread.Sleep(Timeout.Infinite);
}
private void TimerCallback_DoSomething(object stateInfo)
{
// do something
}
}