asp.net - How to prevent a service from stopping on Error -
i wrote windows service polls data on timeintervalls , writes them in database. if there occures error writing database , service stops. want robust solution goes on if error occures.
i put try/catch bocks around every action done service in onstart, onstop , dispose sopped anyway.
is try/catch correct approach? , have put it? put try/catch in main method?
many thanks.
try wrapping call in transactionscope, roll failed changes trying make , should not break on failure.
using (var scope = new transactionscope()) { deletestuff(); updatestuff(); scope.complete(); }
Comments
Post a Comment