I've used C# for years and I've never come across such a mechanism. You would need some way to tell the OS that the current process is somehow protected from being killed. It's maybe more of an OS question than a language question, actually.
The only way to do it is to create a Windows Service instead of a simple Process. This way, I think you could tell in the Windows services tab to always have it active and execute it as much as you would like. For instance:
protected override void OnStart(string args)
timer = new Timer();
timer.Interval = 12000; //Execute the process every 12 seconds
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Tick);
timer.Enabled = true;
private void timer_Tick(object sender, ElapsedEventArgs e)
Runner.WriteErrorLog("Timer ticked and some job has ben called!");
catch (Exception ex)
Runner.WriteErrorLog("ERROR!!! " + ex.Message);
This WOULD NOT prevent the termination of your process but it would enable you to read the log and find if it has been terminated and re-launch it.
Asked in February 2016Viewed 1,493 timesVoted 11Answered 2 times