예제 #1
0
 private Action<LogEntry> Log(Dispatcher dispatcher)
 {
     return entry =>
     {
         dispatcher.Handle(() => this.OnLog.Invoke(entry));
     };
 }
예제 #2
0
        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;
            };
        }
예제 #3
0
 private Action<bool> Complete(Dispatcher dispatcher, ResourceModel model)
 {
     return result =>
     {
         dispatcher.Handle(async () =>
         {
             model.Complete(result);
             await this.Persist();
         });
     };
 }
예제 #4
0
 private Action<TimeSpan> SetEstimation(Dispatcher dispatcher, ResourceModel model)
 {
     return estimation =>
     {
         dispatcher.Handle(() => model.SetEstimation(estimation));
     };
 }
예제 #5
0
 private Action<long> SetSpeed(Dispatcher dispatcher, ResourceModel model)
 {
     return speed =>
     {
         dispatcher.Handle(() => model.SetSpeed(speed));
     };
 }
예제 #6
0
 private Action<long, long> SetProgress(Dispatcher dispatcher, ResourceModel model)
 {
     return (received, total) =>
     {
         dispatcher.Handle(() => model.SetProgress(received, total));
     };
 }
예제 #7
0
 private Action<string> SetStatus(Dispatcher dispatcher, ResourceModel model)
 {
     return status =>
     {
         dispatcher.Handle(() => model.SetStatus(status));
     };
 }