Exemplo n.º 1
0
 public void OnNotifyIdle()
 {
     if (activeTaskCompletionSource != null)
     {
         ActiveTaskCompletionSource activeTaskCompletionSource = this.activeTaskCompletionSource;
         this.activeTaskCompletionSource = null;
         if (activeTaskCompletionSource.TrySetCompleted())
         {
             return;
         }
     }
     // During ActivateAsync, idle can be null.
     idle?.Set();
 }
Exemplo n.º 2
0
 private async Task RunInstanceWithActiveTaskCompletionSourceProtectionAsync <TResponseParameter>(TaskCompletionSource <TResponseParameter> taskCompletionSource,
                                                                                                  ActiveTaskCompletionSource.ProtectionLevel protectionLevel)
     where TResponseParameter : class
 {
     try
     {
         activeTaskCompletionSource = new ActiveTaskCompletionSource <TResponseParameter>(taskCompletionSource, protectionLevel);
         await instance.RunAsync();
     }
     catch
     {
         activeTaskCompletionSource = null;
         throw;
     }
 }