If there is try-catch-finally or try-finally block then finally block is always executed?
But this is not the case every time. There are scenarios when even finally block dos not execute. What are those scenarios?
There are few scenarios when even finally
block does not get executed. Finally block does not execute when the
following type of exception occurs
•ExecutionEngineException
•StackOverflowException
ExecutionEngineException occurs when there is some error in Common
Language Runtime. A case could be if there is some exception while
executing garbage collection. This exception also occurs if
Environment.FailFast() fired.
StackOverflowException occurs when there is no space available in stack to execute further.
But this is not the case every time. There are scenarios when even finally block dos not execute. What are those scenarios?
There are few scenarios when even finally
block does not get executed. Finally block does not execute when the
following type of exception occurs
•ExecutionEngineException
•StackOverflowException
ExecutionEngineException occurs when there is some error in Common
Language Runtime. A case could be if there is some exception while
executing garbage collection. This exception also occurs if
Environment.FailFast() fired.
StackOverflowException occurs when there is no space available in stack to execute further.