src/Orleans.Core.Abstractions/Utils/PublicOrleansTaskExtensions.cs
/// <summary>
/// Observes and ignores a potential exception on a given Task.
/// If a Task fails and throws an exception which is never observed, it will be caught by the .NET finalizer thread.
/// This function awaits the given task and if the exception is thrown, it observes this exception and simply ignores it.
/// This will prevent the escalation of this exception to the .NET finalizer thread.
/// </summary>
/// <param name="task">The task to be ignored.</param>
Observes and ignores a potential exception on a given Task.
If a Task fails and throws an exception which is never observed, it will be caught by the .NET finalizer thread.
This function awaits the given task and if the exception is thrown, it observes this exception and simply ignores it.
This will prevent the escalation of this exception to the .NET finalizer thread.
Observes and ignores a potential exception on a given Task . If a Task fails and throws an exception which is never observed it will be caught by the . NET finalizer thread . This function awaits the given task and if the exception is thrown it observes this exception and simply ignores it . This will prevent the escalation of this exception to the . NET finalizer thread .
public static void Ignore(this Task task)
        {
            if (task.IsCompleted)
            {
                _ = task.Exception;
            }
            else
            {
                task.ContinueWith(
                    IgnoreTaskContinuation,
                    CancellationToken.None,
                    TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
                    TaskScheduler.Default);
            }
        }
public static void Ignore ( this Task task ) { if ( task . IsCompleted ) { _ = task . Exception ; } else { task . ContinueWith ( IgnoreTaskContinuation , CancellationToken . None , TaskContinuationOptions . OnlyOnFaulted | TaskContinuationOptions . ExecuteSynchronously , TaskScheduler . Default ) ; } }
Observes and ignores a potential exception on a given Task.
Observes and ignores a potential exception on a given Task .
Task
this
task
The task to be ignored.
The task to be ignored .