Scheduling async tasks

It's very common for a XAML application (or really, any kind of application) to have to load a good amount of data on startup to populate its initial state. When doing so it is often important to avoid blocking the UI, for example while reading the filesystem or fetching data from an external API, as we have no idea how long those operations will take. For this reason we generally want data to be fetched from a worker thread, in an asynchronous fashion, while keeping the UI reactive to user actions.

It's of course not limited to the initial state, we want to be able to do asynchronous work almost every time the user clicks on a button or edit a text box.

In the .net world async work can be easily managed by using System.Threading.Tasks.Task, a class representing asynchronous operations and for which C# has nice syntaxic sugar in the form of the (now quite common) async/await keywords.

The general pattern to do async in a XAML context is the fo...

Read full post

Alternative title: "Fix 'Microsoft Learn' examples for 2021".

I am following Microsoft simple introduction to building Windows 10 native applications (see their Windows Learn course). Unfortunately everything is always changing fast (and breaking everything) in the software world and their first XAML example does not build anymore.

After spending a few hours to fix my build I understand enough of the problem to write this short article.

Read full post