Exception Property

Task Parallel System.Threading

Gets the Exception 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:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Exception As AggregateException
C#
public AggregateException Exception { get; }

Remarks

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.

Exceptions

ExceptionCondition
System..::.ObjectDisposedException The Task has been disposed.

See Also