I have a SMS application in C# Windows Forms which needs to run 24*7 . However everytime there is an exception coming up which causes the application to terminate its execution and start after 60 sec (Its in scheduled tasks). My requirement is that it should start in 10 sec after catching the exception . Is there is any classes or methods in C# for fault recovery ?
Asked
Active
Viewed 151 times
0
-
do you have the code for the app? – BugFinder Sep 14 '12 at 07:11
-
What is the nature of the exception(is an application restart necessary?), and what problems do you run into when you do regular try-catch exception handling? – Tormod Sep 14 '12 at 07:41
1 Answers
1
If you want to run an application 24*7 you should create a Windows Service it can be configured at install time to restart in case of failures. See this SO question for details.
Furthermore you might want add an UnhandledExceptionEventHandler to your default application domain by registering it on the AppDomain.UnhandledException. Another interesting event is Application.ThreadException which can be used to handle exceptions occurring in Windows Forms threads.

Community
- 1
- 1

Bas Bossink
- 9,388
- 4
- 41
- 53
-
I tried windows service but it was crashing my application and then we need to restart the server. It was not handling exception properly – idrisjafer Sep 15 '12 at 06:04