private Action<LogEntry> Log(Dispatcher dispatcher) { return entry => { dispatcher.Handle(() => this.OnLog.Invoke(entry)); }; }
private Func<Captcha, Task<string>> GetSolver(Dispatcher dispatcher) { return captcha => { TaskCompletionSource<string> completion = new TaskCompletionSource<string>(); dispatcher.Handle(async () => { string solution = await this.OnCaptcha.Invoke(captcha); if (String.IsNullOrWhiteSpace(solution) == false) { completion.SetResult(solution); } else { completion.TrySetCanceled(captcha.Cancellation); } }); return completion.Task; }; }
private Action<bool> Complete(Dispatcher dispatcher, ResourceModel model) { return result => { dispatcher.Handle(async () => { model.Complete(result); await this.Persist(); }); }; }
private Action<TimeSpan> SetEstimation(Dispatcher dispatcher, ResourceModel model) { return estimation => { dispatcher.Handle(() => model.SetEstimation(estimation)); }; }
private Action<long> SetSpeed(Dispatcher dispatcher, ResourceModel model) { return speed => { dispatcher.Handle(() => model.SetSpeed(speed)); }; }
private Action<long, long> SetProgress(Dispatcher dispatcher, ResourceModel model) { return (received, total) => { dispatcher.Handle(() => model.SetProgress(received, total)); }; }
private Action<string> SetStatus(Dispatcher dispatcher, ResourceModel model) { return status => { dispatcher.Handle(() => model.SetStatus(status)); }; }