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…

2

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

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…

12

Tasks and awaits and Rx! (And Drones!) Oh My!

A few people I work with are tinkering with an off-the-shelf drone in our spare time and so we are writing a C# library to control it. The way it works is you send UDP commands to the drone and you receive a stream of status & navigation UDP packets from it. So everything is…

2

async/await does not “release the thread”

There is some language around async/await that I am going to stop using. I’ve heard others use it as well because it does help get the point across but I believe it is ultimately misleading. Async/await does not “release the thread.” To see this you need to look at one level higher in your call…

7

Cancellable “awaiting” on .NET events continued

Compose, compose, compose. Reuse, reuse, reuse. In the last post on cancellable “awaiting” on .NET events, I was so busy focusing on the wrapping the click event in order to get a smooth async control flow for the caller, I neglected to do the same inside the click event wrapper code. The framework team already…

3

Cancellable “awaiting” on .NET events

My last couple of posts have been inspired by await-ing things (see Lucian’s list) which allow you to use Tasks and the new C# async features to write synchronous looking expressive code around things that are not based on threads. There was one bit that was bothering me in the last post about drag and…

0

Drag and Drop with Tasks & Async

Lucian has an excellent series on turning things into Tasks so that you can can be compose them and await them. The Drag and Drop one caught my eye because it is a similar example to the common Reactive Extension demo of the same thing. Drag and Drop is interesting because it is started by…

0

Tasks are not Threads

One of the common misconceptions I’ve encountered when developers first start using the Task Parallel Library is that they think Tasks are just fancy threads. This is easy to assume because in a common case, calling Task.Run(…), it actually does run the Task activity on a thread from the thread pool. But as Stephen Toub…

2