Async, CancellationToken, and IProgress in 5 Short Examples

Async code isn’t always intuitive, but practicing helps. Let’s take a look at Async, CancellationToken, and IProgress, in a few short examples.

October 7, 2024

Simple ways to notify a user without a MessageBox in WinForms

When sending notifications in a WinForms app, a MessageBox is the only way to go… or is it? Let’s get creative and see what else we might do.

August 16, 2023

How to call an async method from a synchronous one, without deadlocking

Writing async code whenever possible is great, but how do we do it when we’re stuck with legacy (and very synchronous) code?

August 11, 2023

How to log messages to multiple targets with NLog

When it comes to finding a bug in an app, few things beat a good trail of logs. And for writing those logs, few tools beat NLog in simplicity or flexibility. I rarely appreciate just how flexible it is though, so it’s worth spending a little time taking a closer look.

July 2, 2023

Using Tuples and deconstruction to return multiple values in C#

A big challenge with any language is trying to group and organize things sensibly, and returning multiple values is no exception. Let’s check out Tuples and deconstruction, and see how they can help us out.

January 5, 2023

Converting a BackgroundWorker to a Task with TaskCompletionSource

Sometimes the safer way to “update” old code is to leave it be and paint over it with a newer construct. Let’s see how to modernize a BackgroundWorker using Tasks and TaskCompletionSource.

December 6, 2022

Named arguments in C#

Named arguments in C#.. they’ve been around a long time, but does anyone use them? Let’s check out another feature that helps tame wild code.

October 12, 2022

Using string interpolation to craft readable strings in C#

The longer I write software, the more I come to appreciate clear code. String interpolation in C# is just one more way to help us do that.

September 19, 2022

Displaying an IIS hosted site in CEFSharp

Thanks to CEFSharp, we can finally bring WinForms to the web! That didn’t sound right. Okay, let’s just look at hosting a site in IIS and showing it.

August 16, 2022

Host a simple webpage in WinForms with CefSharp

WinForms and the web. Like oil and water, they don’t mix well. But with CEFSharp, they mix a LOT better. Let’s check it out.

June 28, 2022