Exception Property

Task.Exception Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the AggregateException that caused the Task to end prematurely. If the Task completed successfully or has not yet thrown any exceptions, this will return null.

Namespace:  System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

public AggregateException Exception { get; }

Property Value

Type: System.AggregateException
The AggregateException that caused the Task to end prematurely.

Tasks that throw unhandled exceptions store the resulting exception and propagate it wrapped in a AggregateException in calls to Wait or in accesses to the Exception property. Any exceptions not observed by the time the Task instance is garbage collected will be propagated on the finalizer thread. For more information and an example, see [beb51e50-9061-4d3d-908c-56a4f7c2e8c1].

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft