<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Async on InternetException</title><link>https://internetexception.com/tags/async/</link><description>Recent content in Async on InternetException</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 17 Aug 2026 17:27:09 +0200</lastBuildDate><atom:link href="https://internetexception.com/tags/async/index.xml" rel="self" type="application/rss+xml"/><item><title>Short review of Qwen 3.8 27B</title><link>https://internetexception.com/2026/08/17/short-review-of-qwen-3-8-27b/</link><pubDate>Mon, 17 Aug 2026 17:27:09 +0200</pubDate><guid>https://internetexception.com/2026/08/17/short-review-of-qwen-3-8-27b/</guid><description>&lt;p&gt;&lt;a href="https://huggingface.co/Qwen/Qwen3.8-27B" target="_blank" rel="noopener noreferrer"&gt;Qwen 3.8&lt;/a&gt;&#10; is out since Friday, 17 of August. I am running it on my own server since Saturday. I am running &lt;a href="https://huggingface.co/unsloth/Qwen3.8-27B-GGUF" target="_blank" rel="noopener noreferrer"&gt;Q4 quants from unsloth&lt;/a&gt;&#10;.&lt;/p&gt;&#10;&lt;p&gt;So far it feels like a step up from Qwen 3.6 27B, which sometimes had problems figuring stuff in my project that I am developing almost entirely using models - just as a test of how far I can push LLMs in agentic coding - mostly local models, I must add. Qwen 3.8 seems like having no problem at all.&lt;/p&gt;</description></item><item><title>.NET/C# interview questions</title><link>https://internetexception.com/2022/10/26/net-c-interview-questions/</link><pubDate>Wed, 26 Oct 2022 10:21:52 +0200</pubDate><guid>https://internetexception.com/2022/10/26/net-c-interview-questions/</guid><description>&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;a href="https://internetexception.com/2022/10/18/idisposable-interface-pattern/" data-type="URL" data-id="/2022/10/18/idisposable-interface-pattern/"&gt;&lt;code&gt;IDisposable&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/18/supressfinalize-in-idisposable-interface/" data-type="URL" data-id="/2022/10/18/supressfinalize-in-idisposable-interface/"&gt;&lt;code&gt;SupressFinalize&lt;/code&gt; in &lt;code&gt;IDisposable&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;a href="https://internetexception.com/2022/10/19/asynchronous-programming-in-net/" data-type="URL" data-id="/2022/10/19/asynchronous-programming-in-net/"&gt;Asynchronous programming in .NET&lt;/a&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/async-await-in-c/" data-type="post" data-id="491"&gt;&lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;!-- --&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/avoid-deadlock-with-asynchronous-methods/"&gt;Avoid deadlock with &lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt;&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="http://2022/10/19/does-async-await-creates-new-thread/" target="_blank" rel="noopener noreferrer"&gt;Does &lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt; creates new thread?&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/cpu-bound-vs-i-o-bound/"&gt;CPU bound vs I/O bound tasks&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/what-is-synchronizationcontext-in-net/"&gt;SynchronizationContext&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/thread-vs-task-in-net/"&gt;Threads/tasks&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/locking-in-net/" data-type="URL" data-id="/2022/10/19/locking-in-net/"&gt;locking in .NET&lt;/a&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/locking-with-integer/" data-type="post" data-id="513"&gt;locking with integer&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/task-parallel-library-tpl/" data-type="URL" data-id="/2022/10/19/task-parallel-library-tpl/"&gt;TPL&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/threadpool/" data-type="URL" data-id="/2022/10/19/threadpool/"&gt;ThreadPool&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;a href="https://internetexception.com/2022/10/19/net-type-system/" data-type="URL" data-id="/2022/10/19/net-type-system/"&gt;Type system&lt;/a&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/reference-types-vs-value-types/" data-type="URL" data-id="/2022/10/19/reference-types-vs-value-types/"&gt;Reference types vs value types&lt;/a&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/value-types-as-fields-in-objects/" data-type="URL" data-id="/2022/10/19/value-types-as-fields-in-objects/"&gt;value types as fields in objects&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;!-- --&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/what-type-can-not-be-object-field/"&gt;What kind of types cannot be object field?&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/ref-struct-types/" data-type="URL" data-id="/2022/10/19/ref-struct-types/"&gt;&lt;code&gt;ref struct&lt;/code&gt; types&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/strings-in-net/" data-type="post" data-id="535"&gt;Strings in .NET&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/data-structures-in-net/" data-type="post" data-id="537"&gt;Data Structures&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/net-generics/" data-type="URL" data-id="/2022/10/19/net-generics/"&gt;Generics&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/19/covariance-and-contravariance/" data-type="post" data-id="541"&gt;Covariance and Contravariance&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://internetexception.com/2022/10/25/equals-and-gethashcode/" data-type="post" data-id="587"&gt;Equals and GetHashCode&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;a href="https://internetexception.com/2022/10/19/garbage-collector/" data-type="post" data-id="545"&gt;Garbage Collector&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Middleware in OWIN</title><link>https://internetexception.com/2022/10/25/middleware-in-owin/</link><pubDate>Tue, 25 Oct 2022 15:40:45 +0200</pubDate><guid>https://internetexception.com/2022/10/25/middleware-in-owin/</guid><description>&lt;p&gt;There are 2 ways of writing OWIN middleware in ASP.NET Core.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Pure OWIN - usefull if you want to integrate with OWIN compatible module but not written in C#&lt;/li&gt;&#10;&lt;li&gt;ASP.NET Core OWIN middleware&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="aspnet-core-middleware"&gt;ASP.NET Core Middleware:&lt;/h2&gt;&#10;&lt;p&gt;This type of middleware can be:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;delegate of &lt;code&gt;Func&amp;lt;HttpContext, Func&amp;lt;&lt;/code&gt;Task&amp;gt;&lt;code&gt;, Task&amp;gt;&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;class with &lt;a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.imiddleware?view=aspnetcore-7.0" data-type="URL" data-id="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.imiddleware?view=aspnetcore-7.0"&gt;&lt;code&gt;IMiddleware&lt;/code&gt;&lt;/a&gt; imlementation&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;// Do work that can write to the Response.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Invoke&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;// Do logging or other work that doesn&amp;#39;t write to the Response.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;});&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="pure-owin-middleware"&gt;Pure OWIN Middleware:&lt;/h2&gt;&#10;&lt;p&gt;This rather would be used to integrate with OWIN middlewares written in different language, so that ASP.NET Core implementation directly is not possible.&lt;/p&gt;</description></item><item><title>Does async/await creates new thread?</title><link>https://internetexception.com/2022/10/19/does-async-await-creates-new-thread/</link><pubDate>Wed, 19 Oct 2022 12:58:00 +0200</pubDate><guid>https://internetexception.com/2022/10/19/does-async-await-creates-new-thread/</guid><description>&lt;p&gt;In short: &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;Longer explanation:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;task that want to do I/O write call to driver write&lt;/li&gt;&#10;&lt;li&gt;driver operations are performed asynchronously&lt;/li&gt;&#10;&lt;li&gt;write operations on devices is done without CPU involved&lt;/li&gt;&#10;&lt;li&gt;finish of writing is done via interrupt&lt;/li&gt;&#10;&lt;li&gt;interrupt, schedules &lt;code&gt;Deferred Procedure Call&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;DPC&lt;/code&gt; schedules &lt;code&gt;Asynchronous Procedure Call&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;APC&lt;/code&gt; notifies thread that I/O write is done&lt;/li&gt;&#10;&lt;li&gt;task that was doing I/O is scheduled with continuation of its method after I/O is done.&lt;/li&gt;&#10;&lt;li&gt;some threads might need to be borrowed for handling APC and such but &lt;em&gt;no thread is spawn to handle I/O&lt;/em&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;I recommend reading this post: &lt;a href="https://blog.stephencleary.com/2013/11/there-is-no-thread.html" data-type="URL" data-id="https://blog.stephencleary.com/2013/11/there-is-no-thread.html"&gt;&lt;a href="https://blog.stephencleary.com/2013/11/there-is-no-thread.html" target="_blank" rel="noopener noreferrer"&gt;https://blog.stephencleary.com/2013/11/there-is-no-thread.html&lt;/a&gt;&#10;&lt;/a&gt;. This will explain the topic much better than I can.&lt;/p&gt;</description></item><item><title>Avoid deadlock with asynchronous methods</title><link>https://internetexception.com/2022/10/19/avoid-deadlock-with-asynchronous-methods/</link><pubDate>Wed, 19 Oct 2022 12:52:45 +0200</pubDate><guid>https://internetexception.com/2022/10/19/avoid-deadlock-with-asynchronous-methods/</guid><description>&lt;ul&gt;&#10;&lt;li&gt;avoid doing &lt;code&gt;AsyncOperation.Result&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;parent method waits for &lt;code&gt;Result&lt;/code&gt; while child method waits for parent thread to take control, after being done with async I/O&lt;/li&gt;&#10;&lt;li&gt;both waits&lt;/li&gt;&#10;&lt;li&gt;deadlock&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Further read:&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://medium.com/rubrikkgroup/understanding-async-avoiding-deadlocks-e41f8f2c6f5d" target="_blank" rel="noopener noreferrer"&gt;https://medium.com/rubrikkgroup/understanding-async-avoiding-deadlocks-e41f8f2c6f5d&lt;/a&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/15021304/an-async-await-example-that-causes-a-deadlock" target="_blank" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/15021304/an-async-await-example-that-causes-a-deadlock&lt;/a&gt;&#10;&lt;/p&gt;</description></item><item><title>Asynchronous programming in .NET</title><link>https://internetexception.com/2022/10/19/asynchronous-programming-in-net/</link><pubDate>Wed, 19 Oct 2022 09:52:30 +0200</pubDate><guid>https://internetexception.com/2022/10/19/asynchronous-programming-in-net/</guid><description>&lt;p&gt;Asynchronous programming patterns in .NET:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm" data-type="URL" data-id="https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm"&gt;Asynchronous Programming Model&lt;/a&gt; (BeginOperation/EndOperation)&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview" data-type="URL" data-id="https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/event-based-asynchronous-pattern-overview"&gt;Event-based Asynchronous Pattern&lt;/a&gt; (invoke event with result from async job)&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/task-asynchronous-programming-model" target="_blank" rel="noopener noreferrer"&gt;Task-based Asynchronous Pattern&lt;/a&gt;&#10; (Task&amp;lt;&amp;gt;)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Ways of achieving asynchronous code in .NET&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;async, await&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;Task&lt;/code&gt; class API (&lt;code&gt;Run&lt;/code&gt;, &lt;code&gt;WhenAll&lt;/code&gt;, &lt;code&gt;WhenAny&lt;/code&gt;, etc.)&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;ThreadPool.QueueUserWorkItem(ThreadProc);&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Further read:&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://internetexception.com/2022/10/19/async-await-in-c/" data-type="URL" data-id="/2022/10/19/async-await-in-c/"&gt;async/await in .NET&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/" target="_blank" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/&lt;/a&gt;&#10;&lt;/p&gt;</description></item><item><title>async/await in C#</title><link>https://internetexception.com/2022/10/19/async-await-in-c/</link><pubDate>Wed, 19 Oct 2022 09:51:34 +0200</pubDate><guid>https://internetexception.com/2022/10/19/async-await-in-c/</guid><description>&lt;p&gt;&lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt; syntax should be used for &lt;a href="https://internetexception.com/2022/10/19/async-await-in-c/" data-type="post" data-id="491"&gt;I/O bound&lt;/a&gt; asynchronous operations only.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;GetUrlContentLengthAsync&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;HttpClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;getStringTask&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetStringAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;https://docs.microsoft.com/dotnet&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;DoIndependentWork&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;getStringTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Compiler transforms code into a state machine that to track yielding execution for &lt;code&gt;await&lt;/code&gt; and resuming execution when a background job is finished.&lt;/p&gt;&#10;&lt;p&gt;Things to keep in mind:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;async&lt;/code&gt; method needs await&lt;/li&gt;&#10;&lt;li&gt;add &lt;code&gt;Async&lt;/code&gt; suffix to asynchronous methods&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;async void&lt;/code&gt; for &amp;lsquo;Fire and Forget&amp;rsquo; work i.e. event Handlers&lt;/li&gt;&#10;&lt;li&gt;be aware of mixing LINQ with &lt;code&gt;async&lt;/code&gt; lambdas&lt;/li&gt;&#10;&lt;li&gt;wait for tasks in a non-blocking manner (do not use &lt;code&gt;Task.Result&lt;/code&gt; i.e.)&lt;/li&gt;&#10;&lt;li&gt;for tight loops use &lt;code&gt;ValueTasks&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Consider using &lt;code&gt;ConfigureAwait(false)&lt;/code&gt; for performance and for avoiding deadlocks&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Further read:&lt;/p&gt;</description></item><item><title>CPU bound vs I/O bound</title><link>https://internetexception.com/2022/10/19/cpu-bound-vs-i-o-bound/</link><pubDate>Wed, 19 Oct 2022 09:35:37 +0200</pubDate><guid>https://internetexception.com/2022/10/19/cpu-bound-vs-i-o-bound/</guid><description>&lt;p&gt;There are two types of asynchronous operations in .NET.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;I/O bound&lt;/li&gt;&#10;&lt;li&gt;CPU bound&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;For I/O bound &lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt; syntax should be used. TPL should not be used for this. &lt;code&gt;async&lt;/code&gt; methods does not spawns new thread to hand le I/O work asynchronously.&lt;/p&gt;&#10;&lt;p&gt;For CPU bound operations TPL should be used (&lt;code&gt;Task.Run&lt;/code&gt;). This spawns new thread. Performance testing should be done to check if overhead of new thread and context switching is not greater than actual work to be done.&lt;/p&gt;</description></item><item><title>What is asynchronous programming?</title><link>https://internetexception.com/2022/10/17/what-is-asynchronous-programming/</link><pubDate>Mon, 17 Oct 2022 16:25:05 +0200</pubDate><guid>https://internetexception.com/2022/10/17/what-is-asynchronous-programming/</guid><description>&lt;ul&gt;&#10;&lt;li&gt;software often waits for some I/O operation to complete (file operation, network call, database query etc.)&lt;/li&gt;&#10;&lt;li&gt;we can use this time for something productive instead to wait for data to be available or I/O operation to be completed&lt;/li&gt;&#10;&lt;li&gt;with asynchronous programming user can work in the meantime&lt;/li&gt;&#10;&lt;li&gt;not waiting for I/O operations synchronously enhances user experience&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Of course this problem is much more complex. Modern software operates on much more different PC architecture than 20 years ago. Nowadays software must be asynchronous to appear more user friendly and to made better use of modern multi CPU architecture. Right now complex, professional software uses multiple processes, threads on multiple CPUs (CPU you buy is not really *single* CPU) or even utilize GPU for more complex computations (like i.e. video editing software). Before that we mostly had single threaded desktop applications that had &amp;lsquo;please wait&amp;rsquo; or &amp;rsquo;loading&amp;rsquo; pop ups. Right now this is song of the past really and to achieve better User Interfaces that allow to edit tag of your post without changing whole post. With mobile devices on the rise and sometimes lousy cellular network those kind of designs would not be sensible or sometimes impossible to implement. Did you ever happened to reenter some chunk of data into some software because you lost it? Maybe network was down? Or you hit back button by mistake? Right now it belongs to past mostly. All of those would be hard to do with synchronous operations. Right now people are bit spoiled and they tend to leave the page/application if it appears to be slow and not every company can sell &amp;lsquo;one-in-the-market-necessary-for-your-work-software&amp;rsquo; that you will be forced to use. And this is why we have asynchronous operations and this is why we have asynchronous programming model that allows us to program such operations.&lt;/p&gt;</description></item><item><title>ViewFactory for Xamarin application</title><link>https://internetexception.com/2016/07/09/viewfactory-for-xamarin-application/</link><pubDate>Sat, 09 Jul 2016 12:37:00 +0200</pubDate><guid>https://internetexception.com/2016/07/09/viewfactory-for-xamarin-application/</guid><description>&lt;h2 id="first-things-first---why"&gt;First things first - Why?&lt;/h2&gt;&#10;&lt;p&gt;First of all I do not like how creating of views and navigation works in Xamarin. There is much boilerplate needed to just navigate from one page to another. Typically like in &lt;a href="https://developer.xamarin.com/guides/xamarin-forms/getting-started/introduction-to-xamarin-forms/#Navigation" target="_blank" rel="noopener noreferrer"&gt;Xamarin documentation&lt;/a&gt;&#10; we have to obtain &lt;code&gt;INavigation&lt;/code&gt; interface instance, create instance of a new page, create instance of view model and all dependencies it requires. When you page do not require view model things are real easy and Xamarin sample is just enough.&lt;/p&gt;</description></item><item><title>WebSocket libraries comparison</title><link>https://internetexception.com/2014/02/21/websocket-libraries-comparison/</link><pubDate>Fri, 21 Feb 2014 14:38:00 +0100</pubDate><guid>https://internetexception.com/2014/02/21/websocket-libraries-comparison/</guid><description>&lt;p&gt;Web project often requires to push data to clients as fast as possible, whenever it is necessary without waiting for client request. It is perfect for website with real time communication between users, like with online communicators for example. Or document collaboration tools. Or maybe system status updates on long running calculation/tasks performed by server. In every case two way communication mechanism is ideal.&lt;/p&gt;</description></item></channel></rss>