Raw threads and async lambdas

Using async methods/lambdas where they are not expected causes unexpected problems. The typical example I discuss with people is TaskFactory.StartNew() because its an easy way to create Tasks and some people reach for that instead of Task.Run(), but I recently came across some code hitting the same problem while creating threads the traditional way. In…

1

Accessing a .NET bot’s state via dependency injection

[NOTE: This post refers to version 3 of the Bot Framework] When using the .NET BotBuilder SDK’s dialog system, you can access the bot state using the dialog context, but what if you don’t have the dialog context handy? You have two options Pass the context around all the time Use the already built in…

0

Async Main() is available, but hidden

How did I miss this? I love C# and I try to keep up with the latest features. What I didn’t realize until recently is that the C# 7.1 features are already released. And C# 7.1 includes asynchronous Main methods. Awesome! By default, new projects in Visual Studio only work with the latest major version…

2

Setting up Xamarin Live Player

[UPDATE] You no longer need the preview version of Visual Studio. Updated directions can be found in the  Xamarin documentation [ORIGINAL] Xamarin Live Player is a new tool that allows you to live edit an application running on an Android or iOS device. The interesting bit for many, is that you don’t need a Mac…

7

An alternative to ConfigureAwait(false) everywhere

One of the general recommendations you may often read is to use ConfigureAwait(false) in library code. This is so that when the library is used, it does not block the synchronization context in use by the application (e.g. the UI thread). If the library doesn’t know anything about the app, it doesn’t depend on the…

18

Quick dev directory cleanup tip

When cleaning up drive space, the first thing I do is remove the ‘obj’, ‘bin’, and ‘packages’ directories from my development directories. They are temporary and will be rebuilt the next time I build the related project. Because I end up with a lot of little test & sample projects that I don’t refer to…

0

Asynchronous infinite loops instead of timers

Did it occur to you that an infinite loop, with async/await inside it, isn’t really an infinite loop? It looks like one (which is usually bad) but because of the asynchrony, we know that it isn’t executing the entire method at one time. Part executes now, then sometime later it periodically resumes – that sounds kind…

7

Waaaaay oversimplified async/await plumbing

Often, when someone asks “how does this async await stuff actually work”? There is a lot of hand waving or someone says “just use reflection and look at it” but the real compiled code is a complex recursive state machine. So I want to show a (relatively) simplified example that isn’t the real thing but…

0

Windows Live Writer lives on as Open Live Writer!

I am happy to be posting this blog entry from the newly announced Open Live Writer! The most excellent blogging tool has not been actively developed for some time. But efforts have been made and now a fork of that well loved application is now provided as the open source project Open Live Writer under…

0

Tasks are (still) not threads and async is not parallel

I talk to a lot of developers who are either new to .NET or are moving from an older version to the newer platform and tools. As such I’m always trying to think of new ways to describe the nature of Tasks vs Threads and async vs parallel. Modern .NET development is steeped in the…

16