Windows service stops at error...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys,

I have a windows service which runs few timers to perform a certain task,
my code is well wrapped with "Try...Catch"s, but still whenever an error
occurs and an exception is being thrown, it executes the code in the "Catch"
section and instead of continue, the service stops.

What gives?

I want it to continue running even if an exception was cought.

Thanks!

Ori :)
 
This is a frustrating aspect of structured error
handling. Once an error is caught, it won't go back into
the code.

You can do what I have done and go back to using on error
statements:

Sub Demonstration ()
On Error GoTo Demonstration_Error

Code Statements....

Exit Sub
Demonstration_Error:

Code to handle the error....
Resume Next
End Sub

It may not be structured, but it is a lot more flexible
and it allows you to carry on.

HTH
Helen
 
Thanks! will try.

Any idea why is it different than a winform application in which it does not
end the program?
 
Ori :) said:
I have a windows service which runs few timers to perform a certain
task, my code is well wrapped with "Try...Catch"s, but still whenever
an error occurs and an exception is being thrown, it executes the code
in the "Catch" section and instead of continue, the service stops.

/Where/ is the Catch block?
Since you're using Timers, are you /always/ re-enabling them, /even if/
you catch an Exception?

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top