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

I recently learned a nice way to manage your .env files in your Svelte projects. If you're using Rollup as your bundling tool, which is likely to be the case, you can use the node module dotenv to automatically inject the content of a .env file into your web page.

Read full post

A friend asked me today what is a simple way to copy files from a directory (in his case, extract some images from a node module) to the build directory, using Rollup.

My solution is to create a simple plugin like this:

Read full post

Last Friday evening I was following and discussing the 2020 US elections, while I got a really dumb idea: is there a logic behind Trump's use of ALL CAPS when tweeting? And if yes, can people guess correctly what is actually in ALL CAPS when given a lowercase version?

I felt that would be a funny, silly game, so I implemented it the next day.

You can play it right now at https://www.trumpscreaming.site.

Rules are very simple: you're given 6 tweets in a row, all in lowercase, and have to guess which words are supposed to be in ALL CAPS. You're score is then calculated based on your accuracy. That sounds easy, but in fact, some tweets are really hard to guess correctly!

A round looks like this:

game round screenshot

Words underscored in orange can be toggled between their lowercase and uppercase version. You then click on "Verify", which results in this:

game round score screenshot

The list of tweets is already quite big (360+ tweets with more than 2 ALL CAPS words), and new ones are added automatically once per day...

Read full post