Possible Duplicate:
Why use try {} finally {} with an empty try block?
在逐步执行MS .NET代码时,我偶然发现了以下内容:
try { } finally
{
// Called in a finally because it needs to run uninterrupted in order to maintain consistency.
queued = IOThreadScheduler.current.ScheduleCallbackHelper(callback, state);
}
有趣的把戏。谁能捐赠一个解释?
最佳答案
这很可能旨在在ThreadAbortException
存在的情况下执行该行。
根据docs:
引发此异常时,运行时将在结束线程之前执行所有的finally块。
关于c# - 好奇的C#代码-需要一些解释,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5225478/