private async Task DownloadPageAsync(Uri uri, Uri baseAddress, CancellationToken ct = default) { var content = await downloaderService.DownloadWebPageAsync(uri, ct); if (string.IsNullOrEmpty(content)) { return; } var uris = UriHelper.GetAllUrisFromString(content, baseAddress); await readLock.WaitAsync(ct); try { downloadStatuses[uri] = DownloadStatus.Done; CheckIfAllUrisAreDone(); foreach (var filteredUri in uris) { SetStatusIfNotSet(filteredUri, DownloadStatus.NotStarted); } } finally { readLock.Release(); } var args = new DownloadedWebPageEventArgs { Content = content, Uri = uri, }; OnDownloadedPage(args); }
protected virtual void OnDownloadedPage(DownloadedWebPageEventArgs e) { DownloadedPageEvent?.Invoke(this, e); }