{"id":1210,"date":"2023-08-16T09:46:56","date_gmt":"2023-08-16T09:46:56","guid":{"rendered":"https:\/\/www.naveedulhaq.com\/?p=1210"},"modified":"2023-08-16T09:46:58","modified_gmt":"2023-08-16T09:46:58","slug":"combining-async-and-yield-in-c","status":"publish","type":"post","link":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/","title":{"rendered":"Combining Async and Yield in C#"},"content":{"rendered":"\n<p>Combining the potency of asynchronous programming with the versatility of iterator blocks using\u00a0<code>yield<\/code>\u00a0can yield elegant and efficient code in <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/csharp\/\" target=\"_blank\" rel=\"noreferrer noopener\">C#<\/a>. Asynchronous operations allow execution without blocking the calling thread, while\u00a0<code>yield<\/code>\u00a0empowers the creation of enumerable sequences. In this guide, we\u2019ll delve into the synergy of async and yield in C#, enhancing the way you manage asynchronous operations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"understanding-async-and-yield\"><strong>Understanding Async and Yield<\/strong> in C#<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Async Programming:<\/strong>&nbsp;C# permits non-blocking execution through asynchronous programming, making it ideal for I\/O-bound operations. Methods marked with the&nbsp;<code>async<\/code>&nbsp;keyword can gracefully pause execution with&nbsp;<code>await<\/code>, resuming once the awaited task completes.<\/li>\n\n\n\n<li><strong>Yield and Enumerator:<\/strong>&nbsp;The&nbsp;<code>yield<\/code>&nbsp;keyword, employed in iterator methods, molds an enumerator that dispenses a sequence of values. The method halts at each&nbsp;<code>yield<\/code>&nbsp;statement, returning the yielded value to the caller. When the enumerator is iterated, the method recommences from its pause point.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"combining-async-and-yield-downloading-and-processing-urls\"><strong>Combining Async and Yield: Downloading and Processing URLs<\/strong><\/h2>\n\n\n\n<p>Let\u2019s dive into a practical example that unites async and yield to download and process a sequence of URLs. Imagine having a list of URLs that require asynchronous download and processing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public async IAsyncEnumerable&lt;string&gt; DownloadAndProcessUrlsAsync(IEnumerable&lt;string&gt; urls)\n{\n    foreach (var url in urls)\n    {\n        using var client = new HttpClient();\n        var response = await client.GetAsync(url);\n        var content = await response.Content.ReadAsStringAsync();\n        \n        yield return content;\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>In this example, the&nbsp;<code>DownloadAndProcessUrlsAsync<\/code>&nbsp;method engages in asynchronous downloading of URL content, subsequently yielding it to the caller. This amalgamation of async and yield provides a streamlined approach to handling asynchronous operations for data sequences.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"consuming-the-async-yield-method\"><strong>Consuming the Async Yield Method<\/strong><\/h2>\n\n\n\n<p>To consume the async yield method, harness the&nbsp;<code>await foreach<\/code>&nbsp;statement introduced in C# 8. This statement adeptly traverses the enumerable sequence asynchronously, while awaiting each yielded value.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var urls = new List&lt;string&gt; { \"https:\/\/example.com\", \"https:\/\/example.org\" };\n\nawait foreach (var content in DownloadAndProcessUrlsAsync(urls))\n{\n    \/\/ Process the content asynchronously\n    Console.WriteLine(content.Length);\n}\n<\/code><\/pre>\n\n\n\n<p>The&nbsp;<code>await foreach<\/code>&nbsp;construct masterfully manages asynchronous iteration, ensuring each yielded value is processed seamlessly without impeding the calling thread.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"benefits-of-async-yield\"><strong>Benefits of Async Yield<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Memory Efficiency:<\/strong>&nbsp;Async yield empowers handling sizable datasets or data streams sans loading everything into memory concurrently. This proves especially advantageous when grappling with files, databases, or network responses.<\/li>\n\n\n\n<li><strong>Non-Blocking:<\/strong>&nbsp;The fusion of async and yield ensures asynchronous operations operate without obstructing the main thread, optimizing application responsiveness.<\/li>\n\n\n\n<li><strong>Simplified Code:<\/strong>&nbsp;Async yield promotes cleaner, more readable code by abstracting the intricacies of asynchronous operations and iterator logic.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"real-world-example-reading-large-files\"><strong>Real-World Example: Reading Large Files<\/strong><\/h2>\n\n\n\n<p>Consider a scenario where you must asynchronously read and process an extensive text file line by line. Here, async yield proves remarkably efficient, enabling you to tackle the file line by line sans loading the entire file into memory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public async IAsyncEnumerable&lt;string&gt; ReadLinesAsync(string filePath)\n{\n    using var reader = new StreamReader(filePath);\n    string line;\n    while ((line = await reader.ReadLineAsync()) != null)\n    {\n        yield return line;\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>Employing&nbsp;<code>await foreach<\/code>&nbsp;to consume this method empowers you to process each file line upon reading, devoid of the need to load the entire file into memory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>The combination of async and yield in C# crafts a compelling approach for managing asynchronous operations on enumerable sequences. By harnessing async yield, you create efficient, non-blocking code for data processing, all while preserving code simplicity. This technique shines brightly when working with substantial datasets, streams, or sequences of asynchronous tasks, offering the means to craft code that\u2019s both high-performing and effortlessly comprehensible. Whether dealing with network requests, file processing, or any asynchronous task, async yield offers an elegant solution that elevates the efficiency and responsiveness of your applications.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.naveedulhaq.com\/index.php\/category\/dot-net-core\/\">Read m<\/a><a href=\"https:\/\/www.naveedulhaq.com\/index.php\/category\/dot-net-core\/\" target=\"_blank\" rel=\"noreferrer noopener\">ore C#\/.NET tutorials Here!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Combining the potency of asynchronous programming with the versatility of iterator blocks using\u00a0yield\u00a0can yield elegant and efficient code in C#. Asynchronous operations allow execution without&#8230;<\/p>\n","protected":false},"author":3,"featured_media":641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[11,8,62,37,32,23,56],"class_list":["post-1210","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dot-net-core","tag-dot-net-core","tag-dot-net-framework","tag-asp-net","tag-c","tag-developer","tag-development","tag-visual-studio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Combining Async and Yield in C# - Naveed Ul-Haq&#039;s blog<\/title>\n<meta name=\"description\" content=\"Combining async and yield in C# crafts a compelling approach for managing asynchronous operations on enumerable sequences.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Combining Async and Yield in C# - Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"og:description\" content=\"Combining async and yield in C# crafts a compelling approach for managing asynchronous operations on enumerable sequences.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-16T09:46:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-16T09:46:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png\" \/>\n\t<meta property=\"og:image:width\" content=\"240\" \/>\n\t<meta property=\"og:image:height\" content=\"240\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abdul Mannan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abdul Mannan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/\"},\"author\":{\"name\":\"Abdul Mannan\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/8babf3cd198e47e5c727f67880ea7977\"},\"headline\":\"Combining Async and Yield in C#\",\"datePublished\":\"2023-08-16T09:46:56+00:00\",\"dateModified\":\"2023-08-16T09:46:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/\"},\"wordCount\":527,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"keywords\":[\".net core\",\".net framework\",\"asp.net\",\"c#\",\"developer\",\"development\",\"visual-studio\"],\"articleSection\":[\".NET\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/\",\"name\":\"Combining Async and Yield in C# - Naveed Ul-Haq&#039;s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"datePublished\":\"2023-08-16T09:46:56+00:00\",\"dateModified\":\"2023-08-16T09:46:58+00:00\",\"description\":\"Combining async and yield in C# crafts a compelling approach for managing asynchronous operations on enumerable sequences.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"contentUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"width\":240,\"height\":240,\"caption\":\".net\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/combining-async-and-yield-in-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Combining Async and Yield in C#\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\",\"name\":\"Naveed Ul-Haq's blog\",\"description\":\"AI, Optimizely, Azure &amp; more\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.naveedulhaq.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\",\"name\":\"Naveed Ul-Haq\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"caption\":\"Naveed Ul-Haq\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\"},\"description\":\"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\\\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\\\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.\",\"sameAs\":[\"https:\\\/\\\/www.naveedulhaq.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedulhaq\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/8babf3cd198e47e5c727f67880ea7977\",\"name\":\"Abdul Mannan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"caption\":\"Abdul Mannan\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Combining Async and Yield in C# - Naveed Ul-Haq&#039;s blog","description":"Combining async and yield in C# crafts a compelling approach for managing asynchronous operations on enumerable sequences.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/","og_locale":"en_GB","og_type":"article","og_title":"Combining Async and Yield in C# - Naveed Ul-Haq&#039;s blog","og_description":"Combining async and yield in C# crafts a compelling approach for managing asynchronous operations on enumerable sequences.","og_url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/","og_site_name":"Naveed Ul-Haq&#039;s blog","article_published_time":"2023-08-16T09:46:56+00:00","article_modified_time":"2023-08-16T09:46:58+00:00","og_image":[{"width":240,"height":240,"url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","type":"image\/png"}],"author":"Abdul Mannan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Abdul Mannan","Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#article","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/"},"author":{"name":"Abdul Mannan","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/8babf3cd198e47e5c727f67880ea7977"},"headline":"Combining Async and Yield in C#","datePublished":"2023-08-16T09:46:56+00:00","dateModified":"2023-08-16T09:46:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/"},"wordCount":527,"commentCount":0,"publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","keywords":[".net core",".net framework","asp.net","c#","developer","development","visual-studio"],"articleSection":[".NET"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/","url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/","name":"Combining Async and Yield in C# - Naveed Ul-Haq&#039;s blog","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#primaryimage"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","datePublished":"2023-08-16T09:46:56+00:00","dateModified":"2023-08-16T09:46:58+00:00","description":"Combining async and yield in C# crafts a compelling approach for managing asynchronous operations on enumerable sequences.","breadcrumb":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#primaryimage","url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","contentUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","width":240,"height":240,"caption":".net"},{"@type":"BreadcrumbList","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/combining-async-and-yield-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.naveedulhaq.com\/"},{"@type":"ListItem","position":2,"name":"Combining Async and Yield in C#"}]},{"@type":"WebSite","@id":"https:\/\/www.naveedulhaq.com\/#website","url":"https:\/\/www.naveedulhaq.com\/","name":"Naveed Ul-Haq's blog","description":"AI, Optimizely, Azure &amp; more","publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.naveedulhaq.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9","name":"Naveed Ul-Haq","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","caption":"Naveed Ul-Haq"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g"},"description":"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.","sameAs":["https:\/\/www.naveedulhaq.com","https:\/\/www.linkedin.com\/in\/naveedulhaq\/"]},{"@type":"Person","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/8babf3cd198e47e5c727f67880ea7977","name":"Abdul Mannan","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","caption":"Abdul Mannan"}}]}},"_links":{"self":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/1210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/comments?post=1210"}],"version-history":[{"count":0,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/1210\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media\/641"}],"wp:attachment":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media?parent=1210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/categories?post=1210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/tags?post=1210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}