コード例 #1
0
 private static async Task DoWaitAsync(Task task, CancellationToken cancellationToken)
 {
     using (CancellationTokenTaskSource <object> cancelTaskSource = new CancellationTokenTaskSource <object>(cancellationToken))
     {
         await(await Task.WhenAny(task, cancelTaskSource.Task).ConfigureAwait(false));
     }
 }
コード例 #2
0
 private static async Task <TResult> DoWaitAsync <TResult>(Task <TResult> task, CancellationToken cancellationToken)
 {
     using (CancellationTokenTaskSource <TResult> cancelTaskSource = new CancellationTokenTaskSource <TResult>(cancellationToken))
     {
         return(await(await Task.WhenAny <TResult>(new Task <TResult>[2]
         {
             task,
             cancelTaskSource.Task
         }).ConfigureAwait(false)));
     }
 }
コード例 #3
0
 private static async Task <TResult> DoWaitAsync <TResult>(Task <TResult> task, CancellationToken cancellationToken)
 {
     using (var cancelTaskSource = new CancellationTokenTaskSource <TResult>(cancellationToken))
         return(await await Task.WhenAny(task, cancelTaskSource.Task).ConfigureAwait(false));
 }