<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Oğuzhan Ağır</title>
    <description>The latest articles on Forem by Oğuzhan Ağır (@oguzhan-agir-02).</description>
    <link>https://forem.com/oguzhan-agir-02</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3539671%2Fd3984a88-381b-49c9-8803-19e8e6f03508.jpg</url>
      <title>Forem: Oğuzhan Ağır</title>
      <link>https://forem.com/oguzhan-agir-02</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/oguzhan-agir-02"/>
    <language>en</language>
    <item>
      <title>React Performance: Preventing Unnecessary Re-renders</title>
      <dc:creator>Oğuzhan Ağır</dc:creator>
      <pubDate>Wed, 11 Mar 2026 21:47:24 +0000</pubDate>
      <link>https://forem.com/oguzhan-agir-02/react-performance-preventing-unnecessary-re-renders-4n5</link>
      <guid>https://forem.com/oguzhan-agir-02/react-performance-preventing-unnecessary-re-renders-4n5</guid>
      <description>&lt;p&gt;The original and complete version of this article is available on the ASP.NET Zero blog:&lt;br&gt;
&lt;a href="https://aspnetzero.com/blog/react-performance-and-preventing-unnecessary-renders" rel="noopener noreferrer"&gt;https://aspnetzero.com/blog/react-performance-and-preventing-unnecessary-renders&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React applications can sometimes feel slow even when everything appears to work correctly. The UI renders, no errors occur, yet interactions feel sluggish. Buttons respond with slight delays, scrolling may stutter, and typing can occasionally feel laggy.&lt;/p&gt;

&lt;p&gt;In many cases, the underlying reason is &lt;strong&gt;unnecessary component re-renders&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;React does not rebuild the entire DOM on every update. Instead, when a component renders:&lt;/p&gt;

&lt;p&gt;• The component function executes again&lt;br&gt;
• React generates a new virtual tree&lt;br&gt;
• React compares it with the previous render&lt;br&gt;
• Only the necessary DOM updates are applied&lt;/p&gt;

&lt;p&gt;This means a &lt;strong&gt;re-render does not necessarily mean a DOM update&lt;/strong&gt;. However, every render still executes the component function again, which may involve expensive calculations, large lists, or complex component trees.&lt;/p&gt;
&lt;h2&gt;
  
  
  A Common Cause of Performance Issues
&lt;/h2&gt;

&lt;p&gt;One of the most common causes of unnecessary renders is placing state too high in the component tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HeavyComponent&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though &lt;code&gt;HeavyComponent&lt;/code&gt; does not use the &lt;code&gt;count&lt;/code&gt; state, it will still re-render whenever the parent component renders.&lt;/p&gt;

&lt;p&gt;A better approach is &lt;strong&gt;state colocation&lt;/strong&gt;, meaning state should live in the lowest possible component that actually needs it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Memoization and Referential Stability
&lt;/h2&gt;

&lt;p&gt;React also provides tools such as:&lt;/p&gt;

&lt;p&gt;• &lt;code&gt;React.memo&lt;/code&gt;&lt;br&gt;
• &lt;code&gt;useMemo&lt;/code&gt;&lt;br&gt;
• &lt;code&gt;useCallback&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;These tools help prevent unnecessary renders by stabilizing props and avoiding repeated calculations. However, they should be used carefully, because excessive memoization can add complexity without improving performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering Large Lists
&lt;/h2&gt;

&lt;p&gt;When working with very large lists, rendering every element can become expensive. In such cases, techniques like &lt;strong&gt;virtualization&lt;/strong&gt; can significantly improve performance by rendering only the visible portion of the list.&lt;/p&gt;

&lt;p&gt;Libraries such as:&lt;/p&gt;

&lt;p&gt;• &lt;code&gt;react-window&lt;/code&gt;&lt;br&gt;
• &lt;code&gt;react-virtuoso&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;allow React applications to handle thousands of rows efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure Before Optimizing
&lt;/h2&gt;

&lt;p&gt;Performance optimization should always begin with measurement rather than assumptions. Tools like the &lt;strong&gt;React DevTools Profiler&lt;/strong&gt; help identify which components render, why they render, and how long they take.&lt;/p&gt;

&lt;p&gt;Without profiling, optimization often becomes guesswork.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This post only provides a brief overview of the topic.&lt;/p&gt;

&lt;p&gt;The full article explains in detail:&lt;/p&gt;

&lt;p&gt;• React re-render mechanics&lt;br&gt;
• architectural performance principles&lt;br&gt;
• Context API performance pitfalls&lt;br&gt;
• referential stability problems&lt;br&gt;
• real-world optimization strategies for large React applications&lt;/p&gt;

&lt;p&gt;Read the complete guide here:&lt;br&gt;
&lt;a href="https://aspnetzero.com/blog/react-performance-and-preventing-unnecessary-renders" rel="noopener noreferrer"&gt;https://aspnetzero.com/blog/react-performance-and-preventing-unnecessary-renders&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>performance</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The True Face of Referential Equality and Optimizations in React</title>
      <dc:creator>Oğuzhan Ağır</dc:creator>
      <pubDate>Fri, 06 Mar 2026 20:40:59 +0000</pubDate>
      <link>https://forem.com/oguzhan-agir-02/the-true-face-of-referential-equality-and-optimizations-in-react-3m32</link>
      <guid>https://forem.com/oguzhan-agir-02/the-true-face-of-referential-equality-and-optimizations-in-react-3m32</guid>
      <description>&lt;p&gt;When performance issues arise in React applications, &lt;code&gt;React.memo&lt;/code&gt;, &lt;code&gt;useMemo&lt;/code&gt;, and &lt;code&gt;useCallback&lt;/code&gt; are usually the first things that come to mind. In practice, however, adding these tools often merely complicates the code without delivering the expected performance boost.&lt;/p&gt;

&lt;p&gt;The underlying reason isn't that React is inadequate, but rather a fundamental misunderstanding of &lt;strong&gt;referential equality&lt;/strong&gt; within React's render model and how these optimization tools actually work.&lt;/p&gt;

&lt;h2&gt;
  
  
  React's Decision Mechanism: Value vs. Reference
&lt;/h2&gt;

&lt;p&gt;When deciding whether to re-render a component, React doesn't check the contents of the data (structural equality). Instead, it checks if the data points to the same location in memory (referential equality). It uses a shallow comparison similar to JavaScript's &lt;code&gt;Object.is()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, even though objects &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; have identical content, they point to different memory locations. Therefore, React considers them &lt;strong&gt;completely different&lt;/strong&gt; values. This becomes critical especially when objects, arrays, and functions are passed as props to child components.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Shallow Comparison Preference
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;React.memo&lt;/code&gt;, &lt;code&gt;PureComponent&lt;/code&gt;, and Hook dependency arrays intentionally perform a shallow comparison. If React were to deeply compare every property within objects during every render, the performance cost would be significantly higher.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Child&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="cm"&gt;/* ... */&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Parent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// A new 'options' object is created in memory during every render.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;pageSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Child&lt;/span&gt; &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, every time the &lt;code&gt;Parent&lt;/code&gt; component renders, a new &lt;code&gt;options&lt;/code&gt; object is created in memory. Even though the &lt;code&gt;Child&lt;/code&gt; component is wrapped in &lt;code&gt;React.memo&lt;/code&gt;, the optimization cannot kick in because the reference of the &lt;code&gt;options&lt;/code&gt; prop has changed, causing the &lt;code&gt;Child&lt;/code&gt; to re-render unnecessarily.&lt;/p&gt;

&lt;h2&gt;
  
  
  Impact on the Reconciliation Process
&lt;/h2&gt;

&lt;p&gt;In React, rendering does not mean directly updating the DOM. During the render phase, React generates a new component tree (Fiber tree) and compares it with the previous one (Reconciliation).&lt;/p&gt;

&lt;p&gt;If a component's state or prop references have changed, React re-renders that component and its entire subtree. Even if there are no actual changes to the DOM, constantly changing references force React to perform this comparison repeatedly, wasting CPU cycles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why useMemo and useCallback Fall Short
&lt;/h2&gt;

&lt;p&gt;These two Hooks are designed to keep references stable (memoization), but when implemented incorrectly, they only add overhead to the application.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Limits of useMemo:&lt;/strong&gt; &lt;code&gt;useMemo&lt;/code&gt; is used to cache expensive calculations or keep references stable. However, if a value in the dependency array changes its reference on every render, the calculation inside &lt;code&gt;useMemo&lt;/code&gt; will re-run every time. In this case, not only does the optimization fail, but React is also burdened with the extra work of tracking these dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Role of useCallback:&lt;/strong&gt; &lt;code&gt;useCallback&lt;/code&gt; caches function definitions. But if a function depends on a frequently updated state (e.g., state changing on every keystroke in a text input), this function will be recreated with every keystroke. Passing this function as a prop to child components will cause them to continuously re-render as well.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Every Render Creates Its Own Scope (Closures)
&lt;/h2&gt;

&lt;p&gt;In React, every render creates its own lexical scope. This means that during each render, a "snapshot" of the current state and prop values is taken.&lt;/p&gt;

&lt;p&gt;Functions within a component capture the values belonging to that specific render. When the state updates, the component re-renders, a new snapshot is taken, and naturally, brand-new functions working with these new values are created in memory. This is React's expected behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architectural Solutions Over Forced Optimization
&lt;/h2&gt;

&lt;p&gt;Instead of trying to forcefully stabilize references using &lt;code&gt;useMemo&lt;/code&gt; and &lt;code&gt;useCallback&lt;/code&gt;, rethinking the component architecture is often a more permanent and cleaner solution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Moving State Down:&lt;/strong&gt; If a piece of state only affects a specific child component, move that state directly into the child rather than keeping it in the parent. This prevents the parent from rendering unnecessarily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lifting Content Up (Children Prop):&lt;/strong&gt; By passing expensive components to a parent via the &lt;code&gt;children&lt;/code&gt; prop, you can ensure that the child components are unaffected when the parent's state changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using Primitive Values:&lt;/strong&gt; Instead of passing an entire object to child components as a prop, pass only the necessary primitive values like &lt;code&gt;string&lt;/code&gt;, &lt;code&gt;number&lt;/code&gt;, or &lt;code&gt;boolean&lt;/code&gt;. Primitives are always compared by value, not by reference.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;React.memo&lt;/code&gt;, &lt;code&gt;useMemo&lt;/code&gt;, and &lt;code&gt;useCallback&lt;/code&gt; are not magic wands. These tools only provide benefits in applications where the architecture and data flow are properly structured. If you are experiencing performance issues, rather than immediately reaching for these Hooks, it is much better to ask architectural questions like, "Where should this component's state live?" or "Do I really need to pass this prop?"&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>architecture</category>
    </item>
    <item>
      <title>When Are Custom Hooks an Advantage in React, and When Do They Become a Liability?</title>
      <dc:creator>Oğuzhan Ağır</dc:creator>
      <pubDate>Fri, 06 Feb 2026 08:34:02 +0000</pubDate>
      <link>https://forem.com/oguzhan-agir-02/when-are-custom-hooks-an-advantage-in-react-and-when-do-they-become-a-liability-4eb0</link>
      <guid>https://forem.com/oguzhan-agir-02/when-are-custom-hooks-an-advantage-in-react-and-when-do-they-become-a-liability-4eb0</guid>
      <description>&lt;p&gt;Custom hooks are one of React’s most powerful abstraction tools but they’re also one of the easiest ways to quietly make a codebase harder to understand.&lt;/p&gt;

&lt;p&gt;In real projects, I’ve often seen hooks introduced with good intentions, only to later cause questions like:&lt;/p&gt;

&lt;p&gt;What does this hook actually do?&lt;/p&gt;

&lt;p&gt;Why is changing this so risky?&lt;/p&gt;

&lt;p&gt;Why do I need to read three hooks to understand one component?&lt;/p&gt;

&lt;p&gt;This article looks at when custom hooks genuinely improve readability and reuse, and when they become a liability due to premature or over generalized abstraction. It focuses on practical signals, concrete examples, and questions you can ask before extracting logic into a hook.&lt;/p&gt;

&lt;p&gt;If you’ve ever wondered whether a hook is simplifying your component or just hiding complexity, you might find this useful:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://aspnetzero.com/blog/react-custom-hooks-pros-cons" rel="noopener noreferrer"&gt;https://aspnetzero.com/blog/react-custom-hooks-pros-cons&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>programming</category>
      <category>typescript</category>
    </item>
    <item>
      <title>An ASP.NET Core + React Template Worth Reviewing</title>
      <dc:creator>Oğuzhan Ağır</dc:creator>
      <pubDate>Thu, 22 Jan 2026 12:06:05 +0000</pubDate>
      <link>https://forem.com/oguzhan-agir-02/an-aspnet-core-react-template-worth-reviewing-3kd6</link>
      <guid>https://forem.com/oguzhan-agir-02/an-aspnet-core-react-template-worth-reviewing-3kd6</guid>
      <description>&lt;p&gt;For those looking for an example of how a starting structure can be set up for ASP.NET Core + React, sharing this as a reference.&lt;/p&gt;

&lt;p&gt;There is a React based UI on the ASP.NET Zero side. It makes it possible to see how concerns such as login, authorization, tenant separation, basic administration pages, and localization are handled on the React side.&lt;/p&gt;

&lt;p&gt;On the frontend, Vite, Ant Design, Redux Toolkit, and TypeScript are used. The backend follows a familiar ASP.NET Core structure.&lt;/p&gt;

&lt;p&gt;For those who want to take a closer look, the article is here:&lt;br&gt;
&lt;a href="https://aspnetzero.com/blog/react-ui-has-arrived-in-aspnet-zero" rel="noopener noreferrer"&gt;https://aspnetzero.com/blog/react-ui-has-arrived-in-aspnet-zero&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>dotnet</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ASP.NET Core Dependency Injection From Scopes &amp; Lifetimes to .NET 9 Source Generators</title>
      <dc:creator>Oğuzhan Ağır</dc:creator>
      <pubDate>Thu, 23 Oct 2025 06:19:24 +0000</pubDate>
      <link>https://forem.com/oguzhan-agir-02/aspnet-core-dependency-injection-from-scopes-lifetimes-to-net-9-source-generators-3f06</link>
      <guid>https://forem.com/oguzhan-agir-02/aspnet-core-dependency-injection-from-scopes-lifetimes-to-net-9-source-generators-3f06</guid>
      <description>&lt;p&gt;Dependency Injection in ASP.NET Core is simple... until you hit a subtle memory leak or a captive dependency bug.&lt;/p&gt;

&lt;p&gt;Are you &lt;em&gt;positive&lt;/em&gt; you're not creating a "captive dependency"? Do you know the right way to use a &lt;code&gt;Scoped&lt;/code&gt; service (like a &lt;code&gt;DbContext&lt;/code&gt;) inside a &lt;code&gt;Singleton&lt;/code&gt; background worker?&lt;/p&gt;

&lt;p&gt;I've just published a guide that goes beyond the basics and dives into the advanced patterns and new features you need to know.&lt;/p&gt;

&lt;p&gt;This isn't just &lt;code&gt;AddTransient&lt;/code&gt; vs. &lt;code&gt;AddScoped&lt;/code&gt; again. We cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Captive Dependency trap&lt;/strong&gt; (and how to fix it).&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;IServiceScopeFactory&lt;/code&gt; in &lt;code&gt;IHostedService&lt;/code&gt; like a pro.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;.NET 9 Source Generators&lt;/strong&gt; for blazing fast startup &amp;amp; Native AOT.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keyed Services&lt;/strong&gt; (&lt;code&gt;[FromKeyedServices("key")]&lt;/code&gt;) for runtime flexibility.&lt;/li&gt;
&lt;li&gt;The Decorator Pattern for clean, cross-cutting concerns.&lt;/li&gt;
&lt;li&gt;Proper async cleanup with &lt;code&gt;IAsyncDisposable&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can move beyond the basics and start writing robust, testable, and high performing DI compatible code. This guide shows you how.&lt;/p&gt;

&lt;h3&gt;
  
  
  👉 &lt;strong&gt;&lt;a href="https://abp.io/community/articles/the-asp.net-core-dependency-injection-system-3vbsdhq8#gsc.tab=0" rel="noopener noreferrer"&gt;Read the Full Guide on ABP.io&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;What's your favorite &lt;code&gt;Dependency Injection&lt;/code&gt; hack? Let me know in the comments! 👇&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>aspnetcore</category>
      <category>webdev</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Building an In-Memory Background Job Queue in ASP.NET Core (Intro + Deep Dive Link)</title>
      <dc:creator>Oğuzhan Ağır</dc:creator>
      <pubDate>Tue, 30 Sep 2025 11:51:53 +0000</pubDate>
      <link>https://forem.com/oguzhan-agir-02/building-an-in-memory-background-job-queue-in-aspnet-core-intro-deep-dive-link-11aj</link>
      <guid>https://forem.com/oguzhan-agir-02/building-an-in-memory-background-job-queue-in-aspnet-core-intro-deep-dive-link-11aj</guid>
      <description>&lt;p&gt;If you've ever wondered how to run asynchronous, long running tasks &lt;em&gt;without&lt;/em&gt; blocking your API responses and &lt;em&gt;without&lt;/em&gt; pulling in external dependencies like Hangfire or RabbitMQ this might interest you.&lt;/p&gt;

&lt;p&gt;In my latest article on ABP Community, I walk through &lt;strong&gt;how to build an in memory background job queue from scratch&lt;/strong&gt; using only built in .NET tooling (&lt;code&gt;IHostedService&lt;/code&gt;, &lt;code&gt;System.Threading.Channels&lt;/code&gt;, dependency injection, etc.). It’s ideal for scenarios where you need lightweight queueing in a single application instance (with the usual caveats). 👇&lt;/p&gt;

&lt;h3&gt;
  
  
  What you’ll learn
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;How to define a &lt;code&gt;IBackgroundTaskQueue&lt;/code&gt; interface&lt;/li&gt;
&lt;li&gt;Implementing it using &lt;code&gt;Channel&amp;lt;T&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Creating a &lt;code&gt;BackgroundService&lt;/code&gt; that continuously dequeues and executes jobs&lt;/li&gt;
&lt;li&gt;Wiring it into the ASP.NET Core DI container&lt;/li&gt;
&lt;li&gt;Pitfalls and limitations of an in memory approach (e.g. job loss upon restart, scalability)&lt;/li&gt;
&lt;li&gt;When to switch to more robust solutions (Hangfire, message brokers)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you like hands on, from scratch tutorials, here’s the full article:&lt;br&gt;
&lt;a href="https://abp.io/community/articles/how-to-build-an-in-memory-background-job-queue-in-asp.net-core-from-scratch-pai2zmtr" rel="noopener noreferrer"&gt;How to Build an In Memory Background Job Queue in ASP.NET Core from Scratch&lt;/a&gt;&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
