views:

114

answers:

2

Hi,

My application uses a thread which should be running continuously. If any exception it should log that exception and should not stop. currently my code is like below. Can any one help me?

void methodname()
{
   try
     {
        while(1)
        executable statements
     }
   catch
     {
       log exception
     }
}
+2  A: 

You have to try/catch the exceptions inside the loop - right now your code exits the loop when an exception is thrown.

RnR
+4  A: 

It needs be something like this:

while(1)
{
 try
 {
 }
 catch()
 {
   //log the exception
 } 
 //continue looping
}
Naveen