Understanding how to use Task and ValueTask

  Рет қаралды 26,584

Microsoft Developer

Microsoft Developer

5 жыл бұрын

Understanding the Whys, what’s, and when’s of ValueTask
devblogs.microsoft.com/dotnet...
ValueTask reference docs
docs.microsoft.com/en-us/dotn...
NuGet package for ValueTask
www.nuget.org/packages/System...
In this episode, Stephen Toub chats with Rich about ValueTask and how it might help reduce allocations and memory usage for your asynchronous .NET code.
[00:34] - What is ValueTask and why do we need it?
[05:22] - What is a good scenario for ValueTask?
[10:00] - What is IValueTask?
[12:14] - Why was the non-generic ValueTask introduced?
[13:54] - Does ValueTask offer cancellation?
[14:42] - What can you do with Task vs ValueTask?
[16:28] - What’s the uptake with ValueTask usage?
[18:28] - How does IAsyncEnumerable task advantage of ValueTask?
[21:11] - What other performance work is happening around allocations?

Пікірлер: 15
@Jason_Shave
@Jason_Shave 5 жыл бұрын
I generally learn most from these when you have some code examples to go along with the discussion. It's very difficult to understand the examples without any reference. Consider doing another video with the various code scenarios Rich has provided (there are many!).
@AdamsTaiwan
@AdamsTaiwan 5 жыл бұрын
I agree. You might like this video: kzbin.info/www/bejne/pHyYZaZuad2FiNU
@AnitShrestha
@AnitShrestha 4 жыл бұрын
@@AdamsTaiwan I had just went through the video and was going to mentioned it. The presentation by Matt is excellent!
@guibirow
@guibirow 5 жыл бұрын
Amazing stuff! This is the kind of topic you have to watch and re-watch a few times to grasp very well. I have read the blog post previously and the video helped a lot to understand some grey areas that I haven't understand properly. The video probably would be 1h long or more to talk through everything. Thanks again!
@philipmrch8326
@philipmrch8326 5 жыл бұрын
This is exactly what I needed haha, thanks for the great content as always!
@CrazySpin3
@CrazySpin3 5 жыл бұрын
I subscribed! Nice video and very informative
@saadbinsami4801
@saadbinsami4801 2 жыл бұрын
Hi, Can you guys do a comparative analysis on Memory and T [ ] ?
@mAcCoLo666
@mAcCoLo666 2 жыл бұрын
How can the data be already there without a cache? If I make the same httpcall twice, the call will be async both times, will it not?
@AdamsTaiwan
@AdamsTaiwan 5 жыл бұрын
Would like to see more examples. I have an app that takes a snapshot of folders/files(with hash codes) on an external drive, saves it to a DataSet then saves it to file or DB. To update I have 2 passes , first pass looks for files in the dataset that have been removed. Second pass checks file system for new or modified files. When I don't have access to the external drive, I can load the DataSet and perform searches or check to see if a set of files on my local drive exist in the DataSet. I'm looking for ways to speed up the process wherever I can.
@ZintomV1
@ZintomV1 3 жыл бұрын
I don't understand, why provide an Async method that returns ValueTask if you know it's always going to return Synchronously? Why not just use a synchronous method instead.
@ehsanehsani2809
@ehsanehsani2809 2 жыл бұрын
Imagine your ValueTask is run 99% sync and 1% async. for example you read a file once and after that others use it synchronously, you may not want to block your thread for that 1% time.
@MorningSire
@MorningSire 2 жыл бұрын
Oh I get it, so ValueTask means value/vask, not a value (type) task :\ I was damn confused about this name for a while
@kenichimori8533
@kenichimori8533 5 жыл бұрын
Multi Value Tasks.
@georgechakhidze8698
@georgechakhidze8698 4 жыл бұрын
Marc Gravel of StackOverflow disagrees, "Prefer ValueTask to Task": blog.marcgravell.com/2019/08/prefer-valuetask-to-task-always-and.html
@nenadvicentic
@nenadvicentic 3 жыл бұрын
That blog post did not consider all edge cases (e.g. `Task.WaitAny/WaitAll`, unknown `IValueTaskSource` implementation). And even with it's narrow analysis, conclusion is lame "always use, even when breaking API, but don't await twice". I'm sure Stephen Toub who wrote most of the TPL and `ValueTask` knows a bit more about the topic.
Working with Channels in .NET
27:41
dotnet
Рет қаралды 30 М.
Stephen Toub - Unlocking performance improvements in .NET
1:11:53
Эффект Карбонаро и бесконечное пиво
01:00
История одного вокалиста
Рет қаралды 6 МЛН
Sprinting with More and More Money
00:29
MrBeast
Рет қаралды 172 МЛН
Which one is the best? #katebrush #shorts
00:12
Kate Brush
Рет қаралды 19 МЛН
TRY NOT TO LAUGH 😂
00:56
Feinxy
Рет қаралды 10 МЛН
A Complete .NET Developer's Guide to Span with Stephen Toub
1:02:48
Stephen Cleary - Asynchronous streams
56:53
DotNext
Рет қаралды 12 М.
C# Tasks Async Await
2:34:08
AngelSix
Рет қаралды 103 М.
High performance IO with System.IO.Pipelines
32:19
Microsoft Developer
Рет қаралды 25 М.
Task vs ValueTask: When Should I use ValueTask?
10:43
Brian Lagunas
Рет қаралды 19 М.
8 await async mistakes that you SHOULD avoid in .NET
21:13
Nick Chapsas
Рет қаралды 308 М.
Exploring NET's Memory Management - A Trip Down Memory Lane
59:12
Exploring Different Disciplines in Your Career with Stephen Toub
48:06
Microsoft Developer
Рет қаралды 2,7 М.
Carregando telefone com carregador cortado
1:01
Andcarli
Рет қаралды 2,7 МЛН
МОЩНЕЕ ТВОЕГО ПК - iPad Pro M4 (feat. Brickspacer)
28:01
ЗЕ МАККЕРС
Рет қаралды 69 М.
i love you subscriber ♥️ #iphone #iphonefold #shortvideo
0:14
Si pamerR
Рет қаралды 2,7 МЛН
cool watercooled mobile phone radiator #tech #cooler #ytfeed
0:14
Stark Edition
Рет қаралды 9 МЛН