Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class TaskExtensions
- {
- private static Action<Task> IgnorerContinuationAction = IgnorerContinuation;
- public static void Ignore(this Task task)
- {
- if (task.IsCompleted)
- {
- var exception = task.Exception;
- }
- else
- {
- task.ContinueWith(
- IgnorerContinuationAction,
- CancellationToken.None,
- TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
- TaskScheduler.Default);
- }
- }
- private static void IgnorerContinuation(Task task)
- {
- var exception = task.Exception;
- }
- }
Add Comment
Please, Sign In to add comment