I have an windows forms application that does a few automation tasks. I would like the app to be able to recover from network errors and carry on doing its tasks when the connection becomes available again.
While the app is doing its tasks I unplug the network cable. I then get the error in the question title. Problem is I don't know what kind of exception that is? Only place I can handle it it seems is with a ThreadExceptionEventHandler, but thats no use since I'm completely out of the flow of tasks now. I need to be able to handle the error with a catch block.
//Small example
while(running == true)
{
try {
dotask1(); //network related tasks
dotask2(); //db tasks
dotask3(); //bla bla
dotask4(); //wishy washy
}开发者_Python百科 catch(Exception e)
{
//Want this to happen, but it never does??
//Sleep here a bit (were in a Backgroundworker here) and continue
System.Threading.Thread.Sleep(int.Parse(ConfigurationManager.AppSettings["TimeoutSleepInterval"]));
continue; //Keep doing tasks 1,2,3,4
//Not even a catch all catches this kind of exception?!?!?
}
}
精彩评论