Issues » #470

#470 – September 04, 2023

The "Weak Event" Pattern in C#

Events in C# are a powerful mechanism for decoupling components and enabling a publisher/subscriber model. However, they have a significant drawback: the publisher holds a strong reference to the subscriber, and this can cause memory leaks. This article describes a pattern for implementing weak events in C#.

Workshop: How to migrate a legacy app to Blazor (sponsor)

Join Ed Charbeneau for a live application-building workshop, where you’ll migrate an existing .NET Web Forms application to Blazor in real time. Learn how to avoid potential roadblocks and master the basic concepts behind .NET 7 and Blazor.

Not all O(1) operations are considered equal

One of the most powerful optimization techniques is to use a cache, which is usually implemented as a dictionary. Today’s tale is about a dictionary, but surprisingly enough, not about a cache.

BearerToken: The new Authentication handler in .NET 8

In ASP.NET Core 8, Microsoft added a new authentication handler named BearerToken. In this blog post, I will explain how it works and its purpose. This handler is part of a bigger push by Microsoft to simplify authentication in ASP.NET Core, but in this blog post, we will focus on this handler.

Reasoning Task, Async & Await in .NET

As developers, we often encounter situations where we need to perform tasks concurrently to ensure our applications run efficiently. The asynchronous programming model in .NET brings us the powerful trio: Task, async, and await. In this post, we'll unravel the mysteries behind these concepts and explore how they enable parallel execution, providing a clear understanding of how they work together.

Measuring Unicode String Lengths with C#

In this short post, we’ll see how you can calculate the actual length of a string using the StringInfo class and why writing to the console might be one of the most complex technical challenges of our time. Well, maybe not, but it’s still damn hard.

"Parse, don't validate" and other type safety driven shenanigans

Making use of the type system is something I feel should be important when working in a strongly typed language like C#. However, I don't feel like that's the case, and I would love for the language to push folks in the direction of creating more robust programs, where the compiler provides more help in proving the correctness of the code.

Free up resources with cancellation while accessing APIs using HTTPClient

In this post I will teach how to free up resources with cancellation while accessing APIs using HTTP Client. All with live working demo.

newsletters

Join over 25,900 readers for a free weekly email with fresh news, articles and tutorials.