Async optimization in C# (ValueTask, Async Eliding, Task.CompletedTask)

preview_player
Показать описание
How to optimize async code? Are ValueTasks always better than Tasks? What is async eliding and what are the benefits and drawbacks?

In this video I wanted to answer all the questions listed above.

Sources:

00:00 ValueTask vs Task
02:23 Async optimizations
06:35 Async eliding pros & cons
10:24 Which async optimization to use?
Рекомендации по теме
Комментарии
Автор

Content is good but you need to increase code example visibility during the walkthrough so it allows the viewers to follow along better.

watchchat
Автор

in the Eliding examples you show the eliding method in the first example only executes at the await which is where you would need to put the try catch. Then in the next example the eliding method executes and throws the exception before it ever hits await. So what is the difference between the two. I wish you would have left the GetSomethingInternalAsync methods the same so we would be comparing apples to apples but as it is, it is confusing. Is Task.FromResult making the difference? Because in the second example all you say when discussing that line is "it will perform anything after the the first await here as well" which makes no sense because no await has been called yet unless you are talking about the await from the previous GetSomethingAsync method called earlier.

AliciaBrinlee
join shbcf.ru