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); }
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); }