Condividi tramite


Task.Exception Proprietà

Definizione

Ottiene l'oggetto AggregateException che ha causato la fine prematura dell'oggetto Task . Se l'oggetto Task completato correttamente o non ha ancora generato eccezioni, verrà restituito null.

public:
 property AggregateException ^ Exception { AggregateException ^ get(); };
public AggregateException Exception { get; }
public AggregateException? Exception { get; }
member this.Exception : AggregateException
Public ReadOnly Property Exception As AggregateException

Valore della proprietà

Oggetto AggregateException che ha causato la fine prematura dell'oggetto Task .

Commenti

Le attività che generano eccezioni non gestite archiviano l'eccezione risultante e lo propagano in un AggregateException oggetto nelle chiamate a Wait o negli accessi alla Exception proprietà . In .NET Framework 4.0, tutte le eccezioni non osservate dal momento in cui l'istanza dell'attività viene propagata al thread finalizzatore, che arresta in modo anomalo il processo. In .NET Framework 4.5 e versioni successive il comportamento predefinito è cambiato in modo che le eccezioni non rilevate non vengano rigenerate dal finalizzatore. .NET Core non rigenera l'eccezione nel finalizzatore. Per altre informazioni e un esempio, vedere Gestione delle eccezioni (Task Parallel Library).For more information and an example, see Exception Handling (Task Parallel Library).

Si applica a