public Task RunAsync(Action <CrawlerResult> result) => Task.Run(() => result(CrawlerResult.Ref( _context.HttpClient.Send(_context.Request) .OnError(Fail(result)) .OnSuccess(r => TaskResult <Stream> .Wait(r.Content.ReadAsStreamAsync()).ForResult()) .OnSuccess(r => _context.HtmlLoader.Load(r.Value)) .OnSuccess(r => ToElement(r.Value)))));
private Action <Exception> Fail(Action <CrawlerResult> callback) => ex => callback(CrawlerResult.Fail(ex));