Skip to content

Latest commit

 

History

History
27 lines (16 loc) · 1.24 KB

systemthreadingtaskstask-no-longer-throw-objectdisposedexception-after.md

File metadata and controls

27 lines (16 loc) · 1.24 KB

System.Threading.Tasks.Task no longer throw ObjectDisposedException after object is disposed

Details

Except for xref:System.Threading.Tasks.Task.System%23IAsyncResult%23AsyncWaitHandle, xref:System.Threading.Tasks.Task?displayProperty=fullName methods no longer throw an xref:System.ObjectDisposedException?displayProperty=fullName exception after the object is disposed.This change supports the use of cached tasks. For example, a method can return a cached task to represent an already completed operation instead of allocating a new task. This was impossible in previous .NET Framework versions, because any consumer of the task could dispose of it, which rendered it unusable.

Suggestion

Be aware that Task methods may no longer throw xref:System.ObjectDisposedException?displayProperty=fullName in cases when the object is disposed. If an app was depending on this exception to know that a task was disposed, it should be updated to explicitly check the task's status using xref:System.Threading.Tasks.Task.Status.

Name Value
Scope Minor
Version 4.5
Type Runtime

Affected APIs

Not detectable via API analysis.