Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

C# Async Yield Return: IAsyncEnumerable will change your life!!!

Автор: Brian Lagunas

Загружено: 2021-05-05

Просмотров: 29349

Описание:

Have you ever wondered if there was an async yield return in C#? Well, there is an async yield return and in this video, I'll show you how to use the yield return statement asynchronously in C#.

When you use the yield return statement in your code, you indicate that the method, operator, or get accessor in which the yield return keyword appears is an iterator. The yield return statement will return one one element in a collection at a time.

The result returned from a yield return iterator method can be consumed by using a foreach statement or LINQ query. Each iteration of the foreach loop calls the iterator method. When a yield return statement is reached in the iterator method, the result is returned and the current location in the iterator method is retained. Upon the execution of the next element in the foreach loop, the iterator method is restarted from the retained location the next time that the iterator method is called.

When working with asynchronous code using async/await, the use of the yield return statement requires just a few small adjustments to your code. Using an async yield return statement requires that the method be asynchronous, making use of async/await.

Usually an async method will return a task. Your first thought when using yield return in your async method may be to have the method return Task of IEnumerable. However, this is not allowed when using yield return, instead your async yield return method must return an IAsyncEnumerable.

You also cannot wait your new async yield return method that returns an IAsynEnumerable. Instead, yo must await the "foreach" statement instead. This is becuase IAsyncEnumerable does not have a GetAwaiter() method. IAsyncEnumerable is an async iterator.

Hopefully this video will help clear up the async yield return usage.

GitHub link: https://github.com/brianlagunas/Yield...

Be sure to watch my new Pluralsight course "Introduction to Prism for WPF":
📺 http://bit.ly/PrismForWpf

Sponsor Me on GitHub:
🙏🏼 http://bit.ly/SponsorBrianOnGitHub

Get 2 Free Stocks on WeBull (Valued up to $1600 when you deposit $100)
💰 http://bit.ly/BrianWeBull

Follow Me:
🐦 Twitter: http://bit.ly/BrianLagunasOnTwitter
📖 Blog: http://bit.ly/BrianLagunasBlog

C# Async Yield Return: IAsyncEnumerable will change your life!!!

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

array(10) { [0]=> object(stdClass)#4290 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "HRXkeaeImGs" ["related_video_title"]=> string(49) "C# Yield Return: What is it and how does it work?" ["posted_time"]=> string(21) "4 года назад" ["channelName"]=> string(13) "Brian Lagunas" } [1]=> object(stdClass)#4263 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "dCj7-KvaIJ0" ["related_video_title"]=> string(47) "Task vs ValueTask: When Should I use ValueTask?" ["posted_time"]=> string(21) "4 года назад" ["channelName"]=> string(13) "Brian Lagunas" } [2]=> object(stdClass)#4288 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "jUZ3VKFyB-A" ["related_video_title"]=> string(61) "The fastest way to iterate a List in C# is NOT what you think" ["posted_time"]=> string(21) "2 года назад" ["channelName"]=> string(12) "Nick Chapsas" } [3]=> object(stdClass)#4295 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "9xY31VV-_QU" ["related_video_title"]=> string(61) "Tame the Power of the Iterator Pattern and yield return in C#" ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(11) "Zoran on C#" } [4]=> object(stdClass)#4274 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "6LCGwrNbJ2g" ["related_video_title"]=> string(80) "Thread → Task. Многопоточность и Асинхронность" ["posted_time"]=> string(21) "2 года назад" ["channelName"]=> string(58) "Архитектор ПО. Александр Желнин" } [5]=> object(stdClass)#4292 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "TFsT8bgs024" ["related_video_title"]=> string(156) "Иван Дашкевич — Yield и async-await: как оно все устроено внутри и как этим воспользоваться" ["posted_time"]=> string(19) "6 лет назад" ["channelName"]=> string(75) "DotNext — конференция для .NET‑разработчиков" } [6]=> object(stdClass)#4287 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "mtTZu8CXaGE" ["related_video_title"]=> string(139) "Многопоточное и асинхронное программирование в .NET. Владимир Крамар .NET Fest 2018" ["posted_time"]=> string(19) "5 лет назад" ["channelName"]=> string(10) "Fest Group" } [7]=> object(stdClass)#4297 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "nec3aZM8aUY" ["related_video_title"]=> string(83) "Deep House Mix 2024 | Deep House, Vocal House, Nu Disco, Chillout Mix by Diamond #3" ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(7) "Diamond" } [8]=> object(stdClass)#4273 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "RnHC1XiNWS8" ["related_video_title"]=> string(94) "Венедиктов – страх, Симоньян, компромиссы / вДудь" ["posted_time"]=> string(21) "6 дней назад" ["channelName"]=> string(10) "вДудь" } [9]=> object(stdClass)#4291 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "zhCRX3B7qwY" ["related_video_title"]=> string(92) "Correcting Common Async/Await Mistakes in .NET 8 - Brandon Minnick - Copenhagen DevFest 2023" ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(15) "NDC Conferences" } }
C# Yield Return: What is it and how does it work?

C# Yield Return: What is it and how does it work?

Task vs ValueTask: When Should I use ValueTask?

Task vs ValueTask: When Should I use ValueTask?

The fastest way to iterate a List in C# is NOT what you think

The fastest way to iterate a List in C# is NOT what you think

Tame the Power of the Iterator Pattern and yield return in C#

Tame the Power of the Iterator Pattern and yield return in C#

Thread → Task. Многопоточность и Асинхронность

Thread → Task. Многопоточность и Асинхронность

Иван Дашкевич — Yield и async-await: как оно все устроено внутри и как этим воспользоваться

Иван Дашкевич — Yield и async-await: как оно все устроено внутри и как этим воспользоваться

Многопоточное и асинхронное программирование в .NET. Владимир Крамар .NET Fest 2018

Многопоточное и асинхронное программирование в .NET. Владимир Крамар .NET Fest 2018

Deep House Mix 2024 | Deep House, Vocal House, Nu Disco, Chillout Mix by Diamond #3

Deep House Mix 2024 | Deep House, Vocal House, Nu Disco, Chillout Mix by Diamond #3

Венедиктов – страх, Симоньян, компромиссы / вДудь

Венедиктов – страх, Симоньян, компромиссы / вДудь

Correcting Common Async/Await Mistakes in .NET 8 - Brandon Minnick - Copenhagen DevFest 2023

Correcting Common Async/Await Mistakes in .NET 8 - Brandon Minnick - Copenhagen DevFest 2023

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]