IAsyncEnumerable, My Favorite C# 8 Feature That No One Is Using

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024
  • Today we'll take a look at IAsyncEnumerable, one of my favorites we got in C# 8!
    Make my day on Patreon & get the source code: / amantinband
    Connect with me on 'em socials:
    Twitter: / amantinband
    LinkedIn: / amantinband
    GitHub: github.com/ama...
    #dotnet #csharp #amantinband

Комментарии • 51

  • @amantinband
    @amantinband  Год назад +6

    Hope you enjoyed the video! Small correction (9:18), ForEachAsync doesn't "materialize" the IAsyncEnumerable. It iterates over it, similar to the await foreach we wrote earlier. Here is the underlying source code: github.com/dotnet/reactive/blob/85f1eb7c53e27cccdbeee3e0b044916168843fcc/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs#L30

  • @MilanJovanovicTech
    @MilanJovanovicTech Год назад +34

    System.Linq.Async? I learned something new 😁

    • @amantinband
      @amantinband  Год назад +3

      Yeah it’s pretty sweet 😎

    • @JDevCode
      @JDevCode Год назад +6

      Are the 2 best channels on RUclips, I learned so much with both. Goats

  • @jamesmussett
    @jamesmussett Год назад +14

    Im lucky enough to use it on a daily basis. Extremely useful when working with sensors, networking, or any kind of real time streaming where the data being returned can potentially be infinite. Great video 👍 keep it up!

  • @egtdig4411
    @egtdig4411 Год назад +1

    Hey, first time viewer of the channel. Thumbs up for the short & informative video, liked it very much. Could you please share what kind of skin are you using for your terminal? It seems very useful.

    • @amantinband
      @amantinband  Год назад

      Thanks! You can follow this step by step: www.hanselman.com/blog/my-ultimate-powershell-prompt-with-oh-my-posh-and-the-windows-terminal

  • @SilasPeters
    @SilasPeters Год назад +1

    The biggest surprise to me is how easy it is to implement lazy code using yields eveywhere!

  • @Abushalabi
    @Abushalabi 6 дней назад

    Very bad example to show the benefits of IAsyncEnumerable

  • @alexlo2621
    @alexlo2621 Год назад +2

    Thank u for the video. I want to suggest another topic related to DDD/Design/Architecture. Could u post a video about anemic code/design? Cons and pros. Thank u.

    • @amantinband
      @amantinband  Год назад +3

      That's a great topic. I'll see if I can create a compelling video. Are you following @codeopinion? He covers this topic in a few different videos, I think

  • @auronedgevicks7739
    @auronedgevicks7739 7 месяцев назад

    lol by the 3min mark I already tuned out. KISS

  • @mlhtest5928
    @mlhtest5928 11 месяцев назад +1

    How do you get IAsyncEnumerable to work in an api contoller or minimal api? No matter what I try it still buffers the responses and sends them all at one time. Thanks

  • @arnonoordover4054
    @arnonoordover4054 Год назад +1

    Correct. Even in the XStreamingElement you cannot use this…😢

  • @OmriKipi
    @OmriKipi Год назад +1

    Thanks ! great video , but the sound quality is not great.

    • @amantinband
      @amantinband  Год назад +1

      I'm struggling to get good sound with the Blue Yeti. I hope the video coming out today has better sound quality. Please let me know if it's still not great! Otherwise, I think it's time to get a better mic 🙂

  • @pianoman1973
    @pianoman1973 Год назад +2

    Great tutorial !

  • @Misteribel
    @Misteribel 2 месяца назад

    Great explanation. For F# programmers, consider using the 'TaskSeq' Nuget Lib, which brings 'await foreach' to F# using Computation Expressions like 'task {...}' and 'seq{...}'.

  • @deus_nsf
    @deus_nsf 8 месяцев назад

    What about EF Core though? How will it interact with it? One SQL request per element of the collection? Or will it fetch all the collection like with a standard List?

  • @MyFuzzyAfterlife
    @MyFuzzyAfterlife Год назад +1

    Random question, but what do you use to draw the boxes and arrows on your screen ? In today’s remote working environment I’m really looking for something this

    • @amantinband
      @amantinband  Год назад +2

      ZoomIt. Check out aka.ms/ZoomIt

  • @HadrielWonda
    @HadrielWonda Год назад

    System.Linq.Async??
    I wonder how long that has been functional 😊

  • @Linkario86
    @Linkario86 Год назад

    Amichai, I'm so glad I found your channel. You're the GOAT

  • @Osirus1156
    @Osirus1156 Год назад

    I agree with your opinion on why it wasn't more widely accepted. I used it quite a bit on a project and we ended up needing to write helper methods just to work with them when those helpers could have just been built in. I am hoping someday Microsoft gives it another pass to consolidate it. It is very nice when calling paged APIs though.

  • @alonmore28
    @alonmore28 8 месяцев назад

    Would you use it as a return type in web api controllers?

  • @thanzeeljalaldeen
    @thanzeeljalaldeen Год назад

    is it possible to get the source code for this please?

  • @SolomonTheStoryTeller
    @SolomonTheStoryTeller Год назад

    all clean architecture implementations I have seen in my 15+ years experience and DDD across several organizations (multi billion dollars)were mostly terrible.
    I have come across a project two years ago that was .net core 3.1 vertical slice cqrs and mediator, fluent result, and angular as frontend.
    It was a beautiful project to work with.
    Clean architecture on the other hand, i am done with it

    • @amantinband
      @amantinband  Год назад

      I've worked on and researched many projects within Microsoft and public open-source projects, and I tend to agree.
      Working in a small aligned team (1-5 devs) is a whole different story than bigger, unaligned teams.

    • @predigr
      @predigr 9 месяцев назад

      So, what architecture to use? where can we find some documentation?

  • @charlesstacyharrisiii2593
    @charlesstacyharrisiii2593 Год назад

    Nicely done! I love the way you explain things. You're a natural teacher!

  • @MrAsishMohapatra
    @MrAsishMohapatra Год назад

    Is it not too much advertisement in a 10 minutes video you have 4-5 ads in between and in the beginning 2?

    • @amantinband
      @amantinband  Год назад

      Yikes.. RUclips controls all my ad placements before and during the video

  • @nayanchoudhary4353
    @nayanchoudhary4353 Год назад

    I just used it today and was wondering about cancellationtoken usage. And just saw your video!Great timing! 🙂
    I see you have used break keyword without cancellation token. I couldn't find such concise explanation anywhere. Thank you!
    But can you explain use of cancellation token with iasyncenumerable?

    • @amantinband
      @amantinband  Год назад +1

      I might do a follow up video on this. Thanks, Nayan!

  • @PetrVejchoda
    @PetrVejchoda Год назад

    this is friggin gamechanger!!! How do I not know about it?? Whares tha catch?? Can you turn it into IObservable??

    • @PetrVejchoda
      @PetrVejchoda Год назад

      can you turn IObservable into IAsyncEnumerable? What the hell? I want to know more!!!

    • @PetrVejchoda
      @PetrVejchoda Год назад

      being able to turn this into IObservable would make some stuff sooooo easy!!

  • @pilotboba
    @pilotboba Год назад

    Do you plan to get back to the DDD / Clean Arch series? :)

    • @amantinband
      @amantinband  Год назад

      Of course, there are still many great topics to cover 👀

  • @robertmrobo8954
    @robertmrobo8954 Год назад

    Why was it named IAsyncEnumerable instead of IEnumerableAsync?

  • @caseyspaulding
    @caseyspaulding Год назад

    Thank you!

  • @justinian.erdmier
    @justinian.erdmier Год назад +1

    This is awesome and I think will solve a pretty nasty bit of code I haven't been able to simplify. One question: Isn't printing the statement "Received 10 numbers" a bit misleading? The Console.WriteLine() only gets called once, but if the NumbersClient only returns a page of 10 (with the range of 0-9), then 11 would only be in our final results if the NumbersClient returned a second page (so actually 20 numbers). I'm not too familiar with the yield keyword, so that part kind of confused me.

    • @amantinband
      @amantinband  Год назад +2

      Yes, it isn't very clear. It would have been clearer to put it right under the call to the client. Sorry about that 🙂

  • @juke-duke
    @juke-duke Год назад

    Are you using Vim for your keybinds?

  • @zlatkorekic
    @zlatkorekic Год назад

    Great content. Highly appreciated 👍

    • @zlatkorekic
      @zlatkorekic Год назад

      Please update VS Code, that notification is taking my attention to often 😁

    • @amantinband
      @amantinband  Год назад +1

      Hahah it's already updated in the video coming out today 😉