private HtmlWeb _htmlWeb = new HtmlWeb();
async Task<SomeData> GetDataAsync()
{
// _htmlWeb.PostResponse += ... ?
// Can the callback be used to handle status codes for these page loads?
var firstPageLoad = _htmlWeb.LoadFromWebAsync(firstUrl);
var secondPageLoad = _htmlWeb.LoadFromWebAsync(secondUrl);
await Task.WhenAll(firstPageLoad, secondPageLoad);
// can't check _htmlWeb.StatusCode here because another thread might have already modified it, or whichever page loaded first might have gotten an error code, which was then overwritten with 200 OK by the second page load
// if either returned anything but 200 OK, handle it or throw an exception...
var firstPage = await firstPageLoad;
var secondPage = await secondPageLoad;
// etc ...
}
private HtmlWeb _htmlWeb = new HtmlWeb();
async Task<SomeData> GetDataAsync()
{
// _htmlWeb.PostResponse += ... ?
// Can the callback be used to handle status codes for these page loads?
var firstPageLoad = _htmlWeb.LoadFromWebAsync(firstUrl);
var secondPageLoad = _htmlWeb.LoadFromWebAsync(secondUrl);
await Task.WhenAll(firstPageLoad, secondPageLoad);
// can't check _htmlWeb.StatusCode here because another thread might have already modified it, or whichever page loaded first might have gotten an error code, which was then overwritten with 200 OK by the second page load
// if either returned anything but 200 OK, handle it or throw an exception...
var firstPage = await firstPageLoad;
var secondPage = await secondPageLoad;
// etc ...
}