Esempio n. 1
0
            public override Task <bool> TryInvokeAsync()
            {
                T item;

                if (_channel.TryRead(out item))
                {
                    try
                    {
                        _action(item);
                        return(ChannelUtilities.TrueTask);
                    }
                    catch (Exception exc)
                    {
                        return(Task.FromException <bool>(exc));
                    }
                }
                return(ChannelUtilities.FalseTask);
            }
Esempio n. 2
0
            public override Task <bool> TryInvokeAsync()
            {
                T item;

                if (_channel.TryRead(out item))
                {
                    try
                    {
                        return(_action(item).ContinueWith(t =>
                        {
                            t.GetAwaiter().GetResult();
                            return true;
                        }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default));
                    }
                    catch (Exception exc)
                    {
                        return(Task.FromException <bool>(exc));
                    }
                }
                return(ChannelUtilities.FalseTask);
            }