Answer the question
In order to leave comments, you need to log in
What is the problem with async/await?
public async void StartAsync()
{
Console.WriteLine(Thread.CurrentThread.ManagedThreadId); // 1
var browser = await GetBrowserAsync(false);
}
private static Browser browser;
private async Task<Browser> GetBrowserAsync(bool headless)
{
if (browser == null)
{
Console.WriteLine(Thread.CurrentThread.ManagedThreadId); // 1
var options = new LaunchOptions { Headless = headless };
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); // Скачиваем Chrome в директорию с exe
Console.WriteLine(Thread.CurrentThread.ManagedThreadId); // 1
browser = await Puppeteer.LaunchAsync(options); // Запускаем браузер
}
return await Task.FromResult(browser);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question