Task.OnExeption() #106803
-
I just wrote this:
It's mainly about handling exceptions of autonomous “set-and-forget” tasks. The method returns a task to which a continuation can be added. If an exception occurs, the continuation will be executed after the exception handling action. The method also catches exceptions thrown when the task is canceled (OperationCanceledException, TaskCanceledException). Is there something like this in .NET already?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Basically, task.ContinueWith(t =>
{
if (t.IsFaulted)
{
action(t.Exception);
}
else if (t.IsCanceled)
{
action(new TaskCanceledException());
}
})
In .NET we don't actually use callback chain. Mixing |
Beta Was this translation helpful? Give feedback.
Basically,
In .NET we don't actually use callback chain. Mixing
await
with callback chain just make things worse.