c# - Are there any circumstances under which the finally block does not get executed? -
this question has answer here:
please note code:
class ctestfinally { public static void run() { try { tryandtry(); } catch (exception exerror) { console.writeline(exerror.message); } { console.writeline("finally...!"); } console.readkey(); } static void tryandtry() { try { tryandtry(); } catch (exception exerror) { console.writeline(exerror.message); } { console.writeline("try: finally...!"); } } } }
finally never executed because stack overflow error.
are there circumstances under block not executed other above problem?
stackoverflowexception
1 of few kinds of exception clr host typically treats specially. asp.net kill worker process example. very hard debug because app goes away. sql server has similar policies i'm sure (like unloading appdomain).
the reason destabilizing condition not allow reliable error recovery (after stack unusable! can example not call logger or send email. there no room on stack.).
another of kind outofmemoryexception (you can't allocate exception - that's why clr pre-allocates 1 oom instance...). think asp.net tolerates while sql server kills appdomain.
for normal exceptions works fine.
Comments
Post a Comment