示例#1
0
 void SetTimedOut() =>
 _taskSource.TrySetException(new TimeoutException($"Timed out after expecting event of type {_eventType} for {_timeout.TimeSpan}"));
示例#2
0
 public static bool TrySetFromTask <T>(this TaskSource <T> target, Task <T> source, CancellationToken candidateToken)
 => source.IsCanceled
         ? target.TrySetCanceled(candidateToken.IsCancellationRequested ? candidateToken : CancellationToken.None)
         : source.Exception != null
             ? target.TrySetException(source.Exception)
             : target.TrySetResult(source.Result);