UaClient/ServiceModel/Ua/ServiceExtensions.cs
/// <summary>
/// Wraps a task with one that may complete as faulted based on a timeout,
/// allowing someone to await a task but be able to break out early by a timeout.
/// </summary>
/// <param name="task">The task to wrap.</param>
/// <param name="millisecondsTimeout">The number of milliseconds to.</param>
/// <returns>The wrapping task.</returns>
Wraps a task with one that may complete as faulted based on a timeout,
allowing someone to await a task but be able to break out early by a timeout.
Wraps a task with one that may complete as faulted based on a timeout allowing someone to await a task but be able to break out early by a timeout .
public static async Task WithTimeoutAfter(this Task task, int millisecondsTimeout)
        {
            if (task == await Task.WhenAny(task, Task.Delay(millisecondsTimeout)).ConfigureAwait(false))
            {
                await task.ConfigureAwait(false);
            }
            else
            {
                throw new TimeoutException();
            }
        }
public static async Task WithTimeoutAfter ( this Task task , int millisecondsTimeout ) { if ( task == await Task . WhenAny ( task , Task . Delay ( millisecondsTimeout ) ) . ConfigureAwait ( false ) ) { await task . ConfigureAwait ( false ) ; } else { throw new TimeoutException ( ) ; } }
Wraps a task with one that may complete as faulted based on a timeout,
allowing someone to await a task but be able to break out early by a timeout.
Wraps a task with one that may complete as faulted based on a timeout allowing someone to await a task but be able to break out early by a timeout .
The wrapping task.
The wrapping task .
Task
this
millisecondsTimeout
int
The number of milliseconds to.
The number of milliseconds to .
task
The task to wrap.
The task to wrap .