#545 – February 23, 2025
with full trimming and NativeAOT support
.NET MAUI Performance Features in .NET 9
11 minutes by Jonathan Peppers, Simon Rozsival
In this post Jonathan and Simon walk us through significant performance improvements for .NET MAUI applications through full trimming and NativeAOT support, enabling smaller app sizes and faster startup times. The update includes enhanced XAML compilation features and new compiled bindings in C# that improve performance and compatibility with trimming. Additionally, developers can now use tools like dotnet-trace and dotnet-gcdump to profile their applications and identify performance bottlenecks across different platforms.
Asynchronous Programming in C#
sponsored by Code Traveler LLC
Brandon Minnick has just released this in-depth course to help you master asynchronous programming using async await in C#, ensuring you’ll never get async/await wrong again!
The Curious Case of .NET ConcurrentDictionary and Closures
3 minutes by Khalid Abuhakmeh
In this article Khalid explains how to optimize ConcurrentDictionary usage by avoiding closures in C#. He demonstrates that when using ConcurrentDictionary's GetOrAdd method, developers should prefer the three-parameter overload (key, valueFactory, and factoryArgument) instead of the common two-parameter version, as it eliminates unnecessary closures, reduces allocations, and prevents potential concurrency and memory leak issues.
Setting application environment variables in IIS without restarts
15 minutes by Andrew Lock
Andrew dives deep explaining various methods to set environment variables for IIS worker processes on Windows. It starts by explaining IIS architecture and its key components, then describes three main approaches to set environment variables: system-wide variables, service-level variables for W3SVC/WAS, and application pool level variables in applicationHost.config. He also covers how to configure these settings using both the IIS UI and command-line tool appcmd.exe, and explains how to prevent automatic app pool restarts when making configuration changes.
.NET Caching: Can a One Second Cache Really Make a Difference?
2 minutes by Dave Callan
How low can we set our cache expiration timeouts to be while still providing performance benefits? In this post Dave demonstrates that implementing even a very short one-second cache can significantly improve application performance. Using Azure Load Testing, he proves that brief caching periods can dramatically reduce database CPU usage while simplifying cache invalidation challenges, making it a viable solution for multi-instance deployments.
Using 'in' C# Keyword as a Parameter Modifier
7 minutes by Scott DePouw
In this article Scott explains the 'in' parameter modifier in C#, which enables passing parameters by readonly reference. When applied to reference types, it prevents modification of the passed parameter, while for value types, it improves performance by avoiding unnecessary copying while maintaining immutability. He also notes that while 'in' isn't beneficial for primitive value types, it's particularly useful for ensuring reference type immutability and optimizing large value type operations.
And the most popular article from the last issue: