Exemplo n.º 1
0
 public override Task <bool> TryInvokeAsync()
 {
     if (_channel.TryWrite(_item))
     {
         try
         {
             _action();
             return(ChannelUtilities.TrueTask);
         }
         catch (Exception exc)
         {
             return(Task.FromException <bool>(exc));
         }
     }
     return(ChannelUtilities.FalseTask);
 }
Exemplo n.º 2
0
 public override Task <bool> TryInvokeAsync()
 {
     if (_channel.TryWrite(_item))
     {
         try
         {
             return(_action().ContinueWith(t =>
             {
                 t.GetAwaiter().GetResult();
                 return true;
             }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default));
         }
         catch (Exception exc)
         {
             return(Task.FromException <bool>(exc));
         }
     }
     return(ChannelUtilities.FalseTask);
 }