当 finally 不在 .net try..finally 块中执行时的条件

Conditions when finally does not execute in a .net try..finally block(当 finally 不在 .net try..finally 块中执行时的条件)
本文介绍了当 finally 不在 .net try..finally 块中执行时的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

基本上我听说某些条件会导致 .net 吹过 finally 块.有谁知道这些条件是什么?

Basically I've heard that certain conditions will cause .net to blow past the finally block. Does anyone know what those conditions are?

推荐答案

两种可能:

  • StackOverflowException
  • ExecutionEngineException

当存在 StackOverflowException 时,finally 块将不会被执行,因为堆栈上没有空间可以执行更多代码.当存在 ExecutionEngineException 时也不会调用它,这可能是由于调用 Environment.FailFast() 引起的.

The finally block will not be executed when there's a StackOverflowException since there's no room on the stack to even execute any more code. It will also not be called when there's an ExecutionEngineException, which may arise from a call to Environment.FailFast().

这篇关于当 finally 不在 .net try..finally 块中执行时的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
How to store delegates in a List(如何将代表存储在列表中)
How delegates work (in the background)?(代表如何工作(在后台)?)
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
Func Delegate vs Function(函数委托与函数)
CreateDelegate with unknown types(具有未知类型的 CreateDelegate)