Trying to understand how Tasks and async/await
It seems everything turns out to make work asynchronously, but this line is not (
Browser = new OpenQA.Selenium.Chrome.ChromeDriver(); Trying to understand how Tasks and async/await
It seems everything turns out to make work asynchronously, but this line is not (
Browser = new OpenQA.Selenium.Chrome.ChromeDriver(); To make something synchronous work asynchronously, we wrap it in:
await Task.Factory.StartNew(()=> { // ΠΊΠ°ΠΊΠΎΠΉ-ΡΠΎ ΡΠΈΠ½Ρ
ΡΠΎΠ½Π½ΡΠΉ ΠΊΠΎΠ΄ }); Or so (from the comments, yes, and more correctly, perhaps):
await Task.Run(()=> { // ΠΊΠ°ΠΊΠΎΠΉ-ΡΠΎ ΡΠΈΠ½Ρ
ΡΠΎΠ½Π½ΡΠΉ ΠΊΠΎΠ΄ }); But this should be done rarely and cautiously - in fact, only long operations (IO and calculations), and then if there is no asynchronous version ... There are a lot of nuances and problems - this solution is hard on the head. In short, you can, but you do not need.
await Task.Run() => {/** some code */} - Ep1demicSource: https://ru.stackoverflow.com/questions/736280/
All Articles