Settling the Biggest Await Async Debate in .NET

Sdílet
Vložit
  • čas přidán 21. 12. 2022
  • Join the NDC Conferences Giveaway: mailchi.mp/nickchapsas/ndc
    Check out my courses: dometrain.com
    Become a Patreon and get source code access: / nickchapsas
    Hello everybody I'm Nick and in this video I will take a look at one of the biggest await async debates in .NET and try to find the best answer for each usecase.
    Workshops: bit.ly/nickworkshops
    Don't forget to comment, like and subscribe :)
    Social Media:
    Follow me on GitHub: bit.ly/ChapsasGitHub
    Follow me on Twitter: bit.ly/ChapsasTwitter
    Connect on LinkedIn: bit.ly/ChapsasLinkedIn
    Keep coding merch: keepcoding.shop
    #csharp #dotnet

Komentáře • 292

  • @theonlywallrus
    @theonlywallrus Před rokem +782

    Yes, please make a video on ConfigureAwait! Great video, thank you

    • @iGexogen
      @iGexogen Před rokem +29

      I have only one question to "ConfigureAwait", why they didn't make false as default?!))

    • @Petoj87
      @Petoj87 Před rokem +8

      This is one of the worst things about async in legacy code..

    • @emerynoel567
      @emerynoel567 Před rokem +4

      Would love to also get your thoughts on legacy code, specifically .NET Framework 4.7.1

    • @abdulmoiz3348
      @abdulmoiz3348 Před rokem +1

      yes yes, we do need this topic in detail please thank youuu.

    • @grant_vine
      @grant_vine Před rokem +5

      Actually my interest on ConfigureAwait extends to MAUI where they only ever load libs as either singleton or transient (concept of scope is a bit irrelevant on a single user app) but specifically the impact of async on a UI app where a lot of this stemmed from (if my memory serves)

  • @PanKJ00
    @PanKJ00 Před rokem +64

    Unless you have measured this is a hot path, avoiding async/await is a premature optimization in my opinion. Some people think many tiny performance gains will add up. But I think in most cases the bottleneck will be something else and the impact of async/await will be negligible. On the other hand, even if a method simply forwards the async call, losing the stack frame can result in losing time when debugging the code later. Especially if there are many layers of "forwarded async methods", it may be very hard to tell how execution ended up in a certain method.
    Of course, this doesn't apply to well-tested libraries that we wouldn't want to debug at all. That's why HttpClient doesn't use async/await where possible for example. Another reason is that library code doesn't "know" how it will be used, so it has to be optimized just in case.
    Note that I have encountered cases where a hot path actually benefited from removing async/await. But these cases are very rare from my experience. And I always had to measure performance before deciding how to optimize such cases anyway.

  • @itssimplymg4682
    @itssimplymg4682 Před rokem +81

    I literally can’t get enough of these videos. And I actually use all this knowledge for my job.
    Thank you for all your content!

  • @stefammagnumfernandesdemen4942

    Use of async/await for sure. Even though the use of disposable is a big deal, the debugging problem is away bigger than that. Getting a more accurate exception stack is, in the majority of the scenarios, much more important than performance.

  • @brianm1864
    @brianm1864 Před rokem +65

    Great video!! I'm typically in the return Task camp myself. And I'd LOVE a video on ConfigureAwait as I've seen/read different things about whether or not it is needed in APIs.

  • @thund3rstruck
    @thund3rstruck Před rokem +15

    I definitely prefer async/await personally. It's clearer to support and understand, especially on a large team of contributors, and the loss of performance in negligible in the vast majority of use cases.

  • @noldor__
    @noldor__ Před rokem +45

    I used to use Task returns myself and also recommended doing the same to others because it looked slightly more clear and I thought it would make fewer calls in the framework. However, once we struggled to diagnose and troubleshoot exceptions efficiently, I quickly switched to using 'await' everywhere. There is no debate, Task returns are evil.

  • @LiaoDrew
    @LiaoDrew Před rokem +1

    This is video is SO TIMELY. We're currently implementing async to our entire codebase. THANK YOU!

  • @slang25
    @slang25 Před rokem +7

    Great video, I've followed the rule of eliding await for "forwarding methods" and middleware, otherwise always await (unless it's performance critical). I like that you are sharing the nuance, not dogmatism

  • @PeterOeC
    @PeterOeC Před rokem +4

    Amazing video (again) thanks! 👍
    I've had colleagues bashing me for using async/await rather than returning the task. However I think I now have some great arguments for keeping it!
    - An error shows in the stacktrace where awaited.
    - Potential gotchas with disposed variables.
    - Not that much slower.
    For majority of problems I sit with, performance has less priority than, potentially introducing bugs.
    The dispose one is particularly scary, cause it might only fail once in a while!
    I'd go with async/await all the time (unless I have a special case).

    • @jrhodes69
      @jrhodes69 Před rokem +1

      The only benefit of eliding the await is performance gain which I would guess is negligible in the majority of cases. If you get bashed again just turn the question around and ask for benchmarks to prove why eliding the await is beneficial in your use case against the more idiomatic usage of async/await (factoring in the gotchas e.g. exceptions, disposing, additional cognitive load of more junior members of the team understanding the nuance)

  • @mustafaazyoksul1372
    @mustafaazyoksul1372 Před rokem +7

    I would love to see a ConfigureAwait video.

  • @precmv
    @precmv Před rokem +26

    A video about the pros/cons of Task vs ValueTask would also be great

    • @nickchapsas
      @nickchapsas  Před rokem +12

      I already have that

    • @precmv
      @precmv Před rokem +5

      @@nickchapsas Apparently I already watched it :D Your videos are great to point our juniors to. Keep it up :)

    • @jongeduard
      @jongeduard Před rokem

      Yep I was thinking the same because curious about that too in this context (being used with async/await versus directly returned). I was thinking about it at the point about Task.FromResult being based on a value type versus reference type.

    • @philg4116
      @philg4116 Před rokem +1

      with better enunciation

    • @Mark-px3rq
      @Mark-px3rq Před rokem

      A fair rule of thumb is, if your function returns a value task, don’t do the unnecessary await, as the use of value task suggests the function will be called in a tight loop where the overhead of the state machine will start to matter more.

  • @Bignickftw
    @Bignickftw Před rokem

    Thank you very much Nick, great video! You uploaded this video just in time when I was looking at David's guidance, after watching your older video about async await 😄

  • @DOSdaze
    @DOSdaze Před rokem

    This is exactly what I've been considering in my async heavy applications that run through multiple layers of calls, thank you for the clarity. And yes, a video on ConfigureAwait would be much appreciated. So many things I thought I understood properly until you made a video on it.

  • @w4.k
    @w4.k Před rokem +22

    The most tricky part about C# is multi threading. It even makes code reviews considerably longer,
    So i would appreciate more videos on the topic.

    • @jongeduard
      @jongeduard Před rokem +7

      I hope you're not thinking that this video was about multithreading?? Because it really isn't. Because async await is not multi-threading.

    • @ziio_dj
      @ziio_dj Před rokem

      Read "Concurrency in C# Cookbook: Asynchronous, Parallel, and Multithreaded Programming" by Stephen Cleary

  • @nickpolyderopoulos3491
    @nickpolyderopoulos3491 Před rokem +1

    I have mostly used the version that does not use async and await. But interestingly enough in the last couple of weeks at work we experience some issues around tasks with deadlocks and one of my co workers found out that if we use async and await in the places that deadlock the deadlock disappears. So on the new year we will have an interesting week trying to decipher that. Your video helps shed some light.
    PS: fun fact that is the second time now where you publish a video that I was searching for. Such a nice coincidence
    Thank you for your time.

  • @abhis9
    @abhis9 Před rokem +12

    When I came over from old Fx WebForms days, I was taught to use async/await all the way. Today I don’t know any better 🤓 I would rather be safe and use it all the way to avoid confusion. Dunno how much perf hit would hurt in my typical LoB projects 🤔.
    And yes, a video about ConfgureAwait would be useful.

  • @bmfdiak
    @bmfdiak Před rokem

    Thank you Nick for your videos and Courses, they are really useful :)
    I'd like to see a video about ConfigureAwaiter as well.
    Happy Holidays!

  • @arztje
    @arztje Před rokem

    This was a deep dive I really needed. Thank you for this content.

  • @xavhow
    @xavhow Před rokem

    Outstanding explanation of returning task vs async-await...
    I just got into habit of using async-await without actually thinking about the difference.
    Thank you Nick!

  • @henrysauzande7975
    @henrysauzande7975 Před rokem +3

    great insights Nick. I usually use async/await in most cases but I came across some code for writing a proxy application which would forward a client request to another external service, and they were using Tasks but wrapped in Task.Run() I kept wondering why they wouldn't just use async/await watching this video I now understand why that was the case very eye opening

  • @Liam-jl4eq
    @Liam-jl4eq Před rokem

    Always inspired by your videos. Thank you for all the lessons. 🙃

  • @kyuksel1985
    @kyuksel1985 Před rokem

    Great video Nick, thank you! I have been using async/await more for the neatness and structure it brings to the code, without realizing the fact that it would create all those stacked up state machines. Will definitely have an impact on my future coding :)

  • @Petoj87
    @Petoj87 Před rokem

    Super great video! I usually use without await, i guessed that it would affect the stacktrace but wasn't 100% until now.

  • @strawhenge5007
    @strawhenge5007 Před rokem +1

    Another thing to consider is if your method has guard clauses. If you use the async/await keywords, the guard clauses won't throw until the caller calls await on the resulting task. Usually you would want guard clauses to throw immediately when the method is called. To get around this, you can move the work to another method that does use async/await, then have your main method (no async/await) just contain the guard clauses then call the second method and return it's task.

  • @JuliusCesarNL
    @JuliusCesarNL Před rokem +23

    A video on ConfigureAwait would be great! I had so many discussions with other developers when or when not to use it. At one point someone claimed that it should be used for literally every async call.. It would be amazing to be able to refer them to your video 😁

    • @maxime4047
      @maxime4047 Před rokem +1

      Configure await is used to refer to the main thread. So important to know when to use it coz it’s a performance impact and deadlock on certain cases. Useful for Maui app for ex but not in backend app.

    • @FXK23
      @FXK23 Před rokem +1

      @@maxime4047 Isn't this standard false in .Net Core (just continue on a free thread)? Thought this was only relevant in .Net framework?

    • @maxime4047
      @maxime4047 Před rokem

      @@FXK23 the standard is true to make sure you don’t get dead lock even if in majority you will use false.
      And configure await true doesn’t mean you get for sure a new thread. It’s just meant that the thread that we continue can be another one

  • @montanomariano
    @montanomariano Před rokem

    Great explanation! I usually return the task itself when I need to await multiple tasks afterwards with task.whenall, but this gets me thinking there are many other use cases

  • @Moosa_Says
    @Moosa_Says Před rokem +1

    I've always used the await way. It seems simple and of course doesn't have using/disposing issue.

  • @stewartsimpson2236
    @stewartsimpson2236 Před rokem

    Excellent video as always! A video on ConfigureAwait would be greatly appreciated from my perspective but also going by a lot of the comments posted here! Thanks

  • @panagiotislamprakis
    @panagiotislamprakis Před rokem +1

    I use both. I return a Task whenever I'm developing a reusable library, and async/await in any other case.

  • @JamieTwells
    @JamieTwells Před rokem +25

    I thought from the thumbnail you were going to weigh up the pros and cons of making API calls using an async vs a sync method like the RestSharp synchronous methods vs HttpClient's async methods. It would be interesting to know what implications for the application both have.

    • @welrocken
      @welrocken Před rokem +4

      You probably shouldn't be calling external API's (or internal, for that matter) synchronously because all that time between the start of the request till the end of the response, you are basically blocking your "thread" (whether that be an HTTP Request Thread for ASPNET.Core or the UI thread for WPF/UWP etc). Async/await is exactly for cases like these, where your thread can not do anything for a given time (reading the file, reading some data from some network etc.), and you do not want your thread (essentially the amount of processing power the CPU/OS gives you) just waiting for stuff.

  • @iGexogen
    @iGexogen Před rokem

    I've always used flexible approach like in your final summary, I call it "make Rider happy". Often changing from async to returning tasks contaminating code with many Task.FromResult(...) / Task.CompletedTask, but I am ok with it. In most cases classes that have such "do something sync and then pass through" logic are abstract base classes, or static helpers/extensions.

  • @kristianaranda
    @kristianaranda Před rokem

    Very good analysis with all the pros and cons of both alternatives.

  • @PedroPabloCalvoMorcillo

    I've always been using explicit async/await approach. Recently I've used Task approach for extension methods that implement a functional pattern.

  • @bsalmeida
    @bsalmeida Před rokem

    Yes, please make a video on ConfigureAwait! Great video, thank you!

  • @Dark3rin0
    @Dark3rin0 Před rokem

    And another great video, thank you so much Nick!

  • @JorgeLuisMachadoTorres
    @JorgeLuisMachadoTorres Před rokem +2

    We follow a simple rule: if your method it's a one-liner do not use async await, for everything else async await all the way.

  • @JoeEnos
    @JoeEnos Před rokem +1

    I’d love the ConfigureAwait video, explaining synchronization context. I’ve never felt confident with that.

  • @JonPerson
    @JonPerson Před rokem +3

    Thanks so much for this important video, Nick! I've gone back and forth on returning a Task, and it's great to feel like the debate is settled. Do you know of any Code Analyzers which can make suggestions which follow your guidelines? I only know of "AsyncFixer" which goes the "return a Task" direction.

  • @allinvanguard
    @allinvanguard Před rokem

    I like to mix it. The default is to include async await, but sometimes within Linq or fluent APIs, it is nice to elide the async await ceremony for more concise syntax. Sometimes it is also a good thing to be able to modify the call stack by hiding passthrough methods for example. For performance reason alone I would never use it, chances are one line of unoptimized user code amounts to thousands of occurences of eliding async / await in performance drag.

  • @avi01224
    @avi01224 Před rokem

    Great video! Lot of things to learn from you. Yes make video on ConfigureAwait 👍

  • @Lior_Banai
    @Lior_Banai Před rokem +1

    The program with files tests is that the os may cache the file access so second access to the same file will be faster.

  • @mranthonymills
    @mranthonymills Před rokem

    I generally do return Task because I get suspicious of too much compiler-generated cruft in my assemblies but I'll keep the issue with disposal in mind, thanks!

  • @snekbaev
    @snekbaev Před rokem +1

    this also alters the behavior on the calling side, say you have two methods A and B that take some value and do the validation. 'A' after validation does an awaited db query, 'B' similar, but not awaited, just returns the task. Now caller can invoke this methods sequentially and await each, but it can also execute them without awaiting and do the awaiting a bit later. If validation fails for either of those methods then exception will be thrown at different stages: or execution or on await.

  • @Pezsmapatkany
    @Pezsmapatkany Před rokem

    A link for the two articles mentioned would be great in the description.
    I use direct Task return when possible, but I burned myself previously with the using stuff, so I can understand the other camp too. I never had problems with debugging or stack traces with this approach.

  • @jongeduard
    @jongeduard Před rokem +1

    Async await is a long subject with a lot of details, reading a ton of things on the internet helped me out, including pages shown by Nick in the video.
    I have also been writing my own async state machine in order to get better understanding of it (after seeing those decompiled examples from ILSpy and Sharplab io) much like I have manually written IEnumerator iterator implementations for same reasons.
    I can almost recommend other people doing those things. Deep understanding of things you use every day can help a lot. Also a lot of experimenting with deadlock situations and high threadpool load.
    All to get a better idea what those smart people on the internet are talking about.

  • @ChristianHowell
    @ChristianHowell Před rokem

    Good video... I can say I wasn't surprised when file reading doesn't change much with async since it still has to read the file line by line... I found that even the TPL doesn't make file reading faster... I am careful as to what gets an ASYNC call. I can remember old style async with BeginInvoke...

  • @AnGeLuz747
    @AnGeLuz747 Před rokem

    So amazing topic...,. It could be so interesting discusing about this and the relation with pool starvation & concurrency. Thank you for your time and share your knowelge with all of us, greetings.

  • @urbanelemental3308
    @urbanelemental3308 Před rokem

    I understand it well so I tend to pass through to the underlying task when it makes sense.

  • @jchandra74
    @jchandra74 Před rokem

    When I don't need to await something in the middle of a method that returns Task (the last thing it does is call an async method that return a Task but nowhere else), I will not turn that method to async/await, but if anything in the middle of the method does require await (2 or more promise chaining), I will do async/await. Reason is... promise style ContinueWith(...) callback is a bit of a pain. I guess need to add another thing for the async/await which is when you use using statement in the method that calls an async method.

  • @anoopsureshnair3564
    @anoopsureshnair3564 Před rokem

    Thank you for this video.
    Please make a video about ConfigureAwait

  • @nanvlad
    @nanvlad Před rokem

    Great video as always! I personally prefer to simplify code and return task itself rather await it. As for me await should be used right in the exact place where the result is truly needed, not just return it from function. For this approach you should write your stack of methods in a functional style (like a middleware pipeline). But if you have a task which relies on an external service, e.g. file, db or api, it’s better to await the result in the same method as it calls to avoid disposal issue. Overusing async/await may be dangerous especially when you want to pass them with lambda as a parameter. For example using Parallel For/Foreach with async lambda leads to conversion of lambda to async void method.
    P.S. ConfigureAwait(false) is a rudiment from the ui apps where there is only one thread that must call and process awaited result to update ui, so for api .net application it’s just redundant

  • @ehvlullo
    @ehvlullo Před rokem +1

    I have been awaiting ever since you told us to Nick

  • @asier9332
    @asier9332 Před rokem +1

    Great video! It'd be nice to have the ConfigureAwait video :)

  • @MarkoKovacina
    @MarkoKovacina Před rokem

    Great video! Very useful!

  • @mightybobka
    @mightybobka Před rokem +3

    Be consistent. Await always!

  • @jscarle
    @jscarle Před rokem +1

    When he says "debugging hangs", he didn't mean that debugging hangs in the IDE, he meant debugging code which causes the application to hang. (Its a subtlety of English.) Because when you debug pause the application, you'll pause at the await of the internal task, not at the await of the calling task.

  • @Shadow_Play3r
    @Shadow_Play3r Před rokem

    yes! more info configureAwait please. I learnt a bit about it when using Unity engine and never again. I generally always declare "false" except for rare UI cases

  • @stephenyork7318
    @stephenyork7318 Před 11 měsíci

    Yes please do a deep dive on ConfigureAwait

  • @StyleNAofficial
    @StyleNAofficial Před rokem +1

    async and await are implementation details. I think letting the caller decide how and when they want to await something is an important case that many haven't brought up. If you're awaiting immediately, you're making a decision for the caller, and therefore the caller would lose that control.

  • @charles_kuperus
    @charles_kuperus Před rokem

    Yes please make a video on Configure Await. I sort of understand, but I know this would help me and all other software developers to understand.

  • @silentdebugger
    @silentdebugger Před rokem

    I was hoping to see ValueTask compared in the benchmarks as well as that sounds like the intended compromise between async performance and functionality for tight-loop code

  • @frankbakker8347
    @frankbakker8347 Před rokem

    Previously I would return the Task whenever possible. This does mean you need to refactor when adding a second async operation so that is a downside. Because of stacktrace and dispose issues I changed my default to 'async unless'

  • @codingbloke
    @codingbloke Před rokem

    Nick. Great video again. Definitely since there is so much older stuff saying use ConfigureAwait it would be a good video. It would help to explain what it does (all that stuff out there mentions the SynchronizationContext but doesn't explain what that is, why you might care and when using ConfigureAwait(false) would actually be bad). Emphasize why Core is different, why doesn't it has this SynchronizationContext thing whatever it is?

  • @entvex
    @entvex Před rokem

    Yes please make a video on configure await :)

  • @alfredoquintanalopez2265

    Yes, please make a video on ConfigureAwait!, thank you

  • @MaxSupercars
    @MaxSupercars Před rokem

    Great video! Thank you! 🙂

  • @Orgbrat
    @Orgbrat Před rokem

    Yes, please make a video on ConfigureAwait!

  • @robertnull
    @robertnull Před rokem

    Nick, I believe you have misunderstood David Fowler's point about exceptions in async methods being "wrapped in Task instead of surprising the caller with an actual exception". What David meant is this difference in behavior:
    async Task Main()
    {
    var task = this.Throw(); // Throw() causes an UnreachableException to be THROWN here
    while (!task.IsCompleted);
    Console.WriteLine(task.Exception); // ThrowAsync() causes task.Exception to be populated with an AggregateException that contains the UnreachableException
    }
    public Task Throw() =>
    throw new UnreachableException();
    public async Task ThrowAsync() =>
    throw new UnreachableException();

  • @devjonie
    @devjonie Před rokem +1

    Your content is among the best, Nick
    Pleeeease do the video on ConfigureAwait.
    I just don't get it.

  • @TrevorJones1
    @TrevorJones1 Před rokem

    Absolutely do a video on ConfigureAwait let's end the confusion once and for all.

  • @mohmadaliyaghmay1117
    @mohmadaliyaghmay1117 Před rokem

    Yes Please make a one for ConfigureAwait too.

  • @renetittel17
    @renetittel17 Před 10 měsíci

    Danke!

  • @donka86
    @donka86 Před rokem

    Yes please. Make a nice video on the synchronization context and configureawait

  • @hotdogfun92
    @hotdogfun92 Před rokem +8

    Great video, but be careful when benchmarking file access from disk, as you need to take into account any underlying caching mechanism such as those afforded by the operating system. In this case, it's probably not a deciding factor, as only the first call of the method doing the very first read would hit the disk and thus have have a higher latency.
    Edit: Depending on the size of the file and on how slow of a disk you read from, the initial latency could skew the benchmark result quite a bit (though, I suspect that this is not the case here)

    • @tomtoups
      @tomtoups Před rokem

      Very good point. Thanks for mentioning that

    • @tomtoups
      @tomtoups Před rokem +2

      also, that probably explains the relatively high standard deviation

  • @justengineering1008
    @justengineering1008 Před rokem

    I am curious, what Benchmark measures while a test returns Task? Logically, in tests we have to await result of tested methods. IMHO

  • @michaelinsberg2185
    @michaelinsberg2185 Před rokem

    Please make a video on ConfigureAwait! Great video, thank you

  • @hanspetervollhorst1
    @hanspetervollhorst1 Před rokem +1

    Yes, please make a Video on ConfigureAwait - or put it in your next course :)

  • @Yupmoh
    @Yupmoh Před rokem

    Yes, please make a video on ConfigureAwait

  • @paulegan3783
    @paulegan3783 Před rokem

    Thanks!

  • @ninodolo
    @ninodolo Před rokem

    Can't wait for the ConfigureAwait video!

  • @igorilyichyov6414
    @igorilyichyov6414 Před rokem

    Great video!

  • @MicroLosi
    @MicroLosi Před rokem

    I'm using only await/async just because of debugging and stack tracing. Though I had one project where some performance was increased just by failing debugability.

  • @Alguem387
    @Alguem387 Před rokem

    I once got a stack overflow form forwarding to many async methods,

  • @rachidme
    @rachidme Před rokem

    Very good video, i use to use it depending on the case.

  • @odee2004
    @odee2004 Před 8 měsíci

    I'm confused, is it recommended to use Async await if you are using a Using statement? Or is it the other way around (do not use async/await)?

  • @emyrulz
    @emyrulz Před rokem

    Depends. If the call is part of a complex Api with may levels I prefer returning tasks. Also if the tasks can be combined or the caller has the option to wait for all of them or not. Returning the task is much more flexible from the caller's perspective.
    Now, in the usual case I prefer to do exactly as you, mostly await and avoid it in trivial forwarding methods.

  • @sanphir
    @sanphir Před rokem

    Yes! ConfigureAwait video please!

  • @dipendupaul
    @dipendupaul Před rokem

    One of the other issues that I faced returning Task without an await, in the calling method it does not report anything if I miss await and async, while in the other case, it is reported with green squiggly. Former resulted in some difficult to debug bugs and wasted hours.

  • @F1nalspace
    @F1nalspace Před rokem

    We program a lot in the WPF world, therefore we often need to do work without blocking the UI, so in the view-model we create a core method that returns a Task and then create an async method that awaits that core method. Sometimes we even create a raw method, that is called from the async method as a simple wrapper task, but this is rare. If i ever see async methods called in a chain, i collapse them down to just one async method. Sometimes i prevent the usage of async entirely and use tasks and wait for them instead - it depends on the use-case.
    But i find it hard to properly secure the methods, so that it wont be called multiple times or can be canceled. Most of the time a simple Interlocked.CompareExchange() and one Exchange() can solve that, but in some cases where multiple calls are actually allowed, that requires much stronger syncronisations.

  • @pcsoriano6787
    @pcsoriano6787 Před rokem

    A video about configure await and use scenarios would be really helpfull :)

  • @inzyster
    @inzyster Před rokem

    Oh yes, a video on ConfigureAwait would be greatly appreciated.

  • @m5s10
    @m5s10 Před rokem

    Please make a video on configure await. Thanks.

  • @hnasser1
    @hnasser1 Před rokem

    yes make a video on ConfigureAwait please. Thanks

  • @anthony8090
    @anthony8090 Před rokem

    I typically only use async/await if I either need the result of the task or want to handle the exception within that method. Otherwise, it seems pretty unnecessary to do so.
    You wouldn't call .ToList() on every IEnumerable you find just because it's easier and to avoid having to enumerate it to an array or list later on, right?

  • @Paulskit
    @Paulskit Před rokem

    It would've been great if ValueTask is mentioned as well. Their behaviour is slightly different as well when comparing async vs just returning.

  • @benjaminboyle3295
    @benjaminboyle3295 Před rokem

    In hotpath code, I will write a non-async method that just returns the task (such as reading from a pipe) if it is already completed successfully (as it usually is). But if the task to be returned is not completed, the method will call an inner, async method that awaits it. So you get the benefit of hotpath not using async machinery most of the time, only using to it when the task hasn't completed successfully.

  • @HackerUC
    @HackerUC Před rokem

    Yes to the ConfigureAwait video 👍

  • @deeplerg7913
    @deeplerg7913 Před rokem +1

    Please link your sources in the description. It really helps.

  • @GufNZ
    @GufNZ Před rokem

    Our company just added a rule to our set of analysers to require async, to improve readability on leaf methods that would otherwise have to return Task.FromResult, and to help avoid returning a null Task, tho #nullable enable helps there too. They also suppressed the suggestion that async without any await could be removed.