这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Sep 2, 2020. It is now read-only.
This repository was archived by the owner on Sep 2, 2020. It is now read-only.

Add "unobserved" exception handling #48

@grantland

Description

@grantland

An “unobserved” exception is one that’s stored into the task but then never looked at in any way by the consuming code. There are many ways of observing the exception, including Wait()’ing on the Task, accessing a Task’s Result, looking at the Task’s Exception property, and so on. If code never observes a Task’s exception, then when the Task goes away, the TaskScheduler.UnobservedTaskException gets raised, giving the application one more opportunity to “observe” the exception. And if the exception still remains unobserved, the exception escalation policy is then enabled by the exception going unhandled on the finalizer thread.

...exceptions indicate something has gone wrong, and crashing helps developers to immediately identify that the application has entered an unreliable state.

(Source: http://blogs.msdn.com/b/pfxteam/archive/2011/09/28/task-exception-handling-in-net-4-5.aspx)

In .NET, "unobserved" exceptions will bubble up and intentionally crash the application. This would be a useful feature to allow developers to be notified (via a crash) of an "unobserved" exception since it means their application has entered an unreliable state.

Since this would be a breaking change, it might be worthwhile to disable this feature by default and require it to be explicitly turned on by developers.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions