<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>C# on martinuke0&#39;s Blog</title>
    <link>https://martinuke0.github.io/tags/c%23/</link>
    <description>Recent content in C# on martinuke0&#39;s Blog</description>
    <image>
      <title>martinuke0&#39;s Blog</title>
      <url>https://martinuke0.github.io/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://martinuke0.github.io/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- 0.152.2</generator>
    <language>en</language>
    <lastBuildDate>Wed, 01 Apr 2026 10:52:43 +0000</lastBuildDate>
    <atom:link href="https://martinuke0.github.io/tags/c%23/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Lazy Initialization: Theory, Practice, and Real‑World Patterns</title>
      <link>https://martinuke0.github.io/posts/2026-04-01-lazy-initialization-theory-practice-and-realworld-patterns/</link>
      <pubDate>Wed, 01 Apr 2026 10:52:43 +0000</pubDate>
      <guid>https://martinuke0.github.io/posts/2026-04-01-lazy-initialization-theory-practice-and-realworld-patterns/</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Lazy initialization (sometimes called &lt;em&gt;lazy loading&lt;/em&gt; or &lt;em&gt;deferred construction&lt;/em&gt;) is a technique in which the creation of an object, the computation of a value, or the acquisition of a resource is postponed until the moment it is actually needed. While the idea sounds simple, applying it correctly can dramatically improve start‑up performance, reduce memory pressure, and simplify complex dependency graphs.&lt;/p&gt;
&lt;p&gt;In this article we will:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Define lazy initialization and distinguish it from related concepts like caching and memoization.&lt;/li&gt;
&lt;li&gt;Explore the benefits and drawbacks, with a focus on thread‑safety and determinism.&lt;/li&gt;
&lt;li&gt;Walk through concrete implementations in Java, C#, Python, and C++.&lt;/li&gt;
&lt;li&gt;Discuss advanced patterns such as double‑checked locking, the &lt;code&gt;Lazy&amp;lt;T&amp;gt;&lt;/code&gt; type in .NET, and integration with dependency‑injection containers.&lt;/li&gt;
&lt;li&gt;Highlight common pitfalls, testing strategies, and performance‑measurement techniques.&lt;/li&gt;
&lt;li&gt;Provide real‑world examples from GUI frameworks, ORMs, and cloud services.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By the end of this post you should be able to decide &lt;strong&gt;when&lt;/strong&gt; lazy initialization is appropriate, &lt;strong&gt;how&lt;/strong&gt; to implement it safely across multiple languages, and &lt;strong&gt;what&lt;/strong&gt; to watch out for when maintaining lazy code in production.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Deep Dive into the Microsoft CCR Session API</title>
      <link>https://martinuke0.github.io/posts/2026-03-31-deep-dive-into-the-microsoft-ccr-session-api/</link>
      <pubDate>Tue, 31 Mar 2026 17:13:11 +0000</pubDate>
      <guid>https://martinuke0.github.io/posts/2026-03-31-deep-dive-into-the-microsoft-ccr-session-api/</guid>
      <description>&lt;h2 id=&#34;table-of-contents&#34;&gt;Table of Contents&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#why-the-concurrency-and-coordination-runtime-ccr-exists&#34;&gt;Why the Concurrency and Coordination Runtime (CCR) Exists&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#core-building-blocks-of-ccr&#34;&gt;Core Building Blocks of CCR&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;3.1 &lt;a href=&#34;#dispatcher&#34;&gt;Dispatcher&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;3.2 &lt;a href=&#34;#port--receiver&#34;&gt;Port &amp;amp; Receiver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;3.3 &lt;a href=&#34;#task-arbiter-and-interleave&#34;&gt;Task, Arbiter, and Interleave&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#the-session-api--overview&#34;&gt;The Session API – Overview&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;4.1 &lt;a href=&#34;#session-lifetime&#34;&gt;Session Lifetime&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;4.2 &lt;a href=&#34;#creating-a-session&#34;&gt;Creating a Session&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;4.3 &lt;a href=&#34;#adding-work-to-a-session&#34;&gt;Adding Work to a Session&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;4.4 &lt;a href=&#34;#cancellation--cleanup&#34;&gt;Cancellation &amp;amp; Cleanup&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#practical-example-1--coordinating-multiple-web-service-calls&#34;&gt;Practical Example 1 – Coordinating Multiple Web Service Calls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#practical-example-2--sensor-fusion-in-a-robotics-scenario&#34;&gt;Practical Example 2 – Sensor Fusion in a Robotics Scenario&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#advanced-topics&#34;&gt;Advanced Topics&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;7.1 &lt;a href=&#34;#nested-sessions&#34;&gt;Nested Sessions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;7.2 &lt;a href=&#34;#session-pooling--reuse&#34;&gt;Session Pooling &amp;amp; Reuse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;7.3 &lt;a href=&#34;#interoperability-with-asyncawait&#34;&gt;Interoperability with async/await&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;7.4 &lt;a href=&#34;#debugging-sessions&#34;&gt;Debugging Sessions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#performance-considerations--common-pitfalls&#34;&gt;Performance Considerations &amp;amp; Common Pitfalls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#ccr-session-api-vs-other-concurrency-models&#34;&gt;CCR Session API vs. Other Concurrency Models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#resources&#34;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;When you build modern, responsive applications—especially in domains like robotics, IoT, or high‑throughput services—handling asynchronous work efficiently becomes a core architectural challenge. Microsoft’s &lt;strong&gt;Concurrency and Coordination Runtime (CCR)&lt;/strong&gt;, originally shipped with &lt;strong&gt;Microsoft Robotics Developer Studio (MRDS)&lt;/strong&gt;, offers a lightweight, message‑driven model for orchestrating asynchronous operations without the overhead of heavyweight threads.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
