|
@@ -424,7 +424,7 @@ namespace StationProbe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async void DoSaveExamImageAsync(IPage page, string examId, int imageIndex, string imageUrl)
|
|
|
+ private async void DoSaveExamImageAsync(IPage page, string examId, int imageIndex, string imageUrl, ManualResetEvent finishEvent)
|
|
|
{
|
|
|
var response = await page.WaitForResponseAsync(imageUrl);
|
|
|
var imageData = await response.BufferAsync();
|
|
@@ -438,14 +438,19 @@ namespace StationProbe
|
|
|
};
|
|
|
_examStore.AddImage(image);
|
|
|
Logger.WriteLine($"Image:{imageUrl} stored.");
|
|
|
+ finishEvent.Set();
|
|
|
}
|
|
|
|
|
|
private async Task SaveExamImageAsync(IPage page, string examId, int imageIndex, string imageUrl)
|
|
|
{
|
|
|
await using (var imagePage = await page.Browser.NewPageAsync())
|
|
|
{
|
|
|
- DoSaveExamImageAsync(imagePage, examId, imageIndex, imageUrl);
|
|
|
+ var finishEvent = new ManualResetEvent(false);
|
|
|
+ finishEvent.Reset();
|
|
|
+ DoSaveExamImageAsync(imagePage, examId, imageIndex, imageUrl, finishEvent);
|
|
|
await imagePage.GoToAsync(imageUrl);
|
|
|
+ finishEvent.WaitOne();
|
|
|
+ finishEvent.Dispose();
|
|
|
}
|
|
|
}
|
|
|
|