I’ve lamented in the past that there is no real async GetFiles. But that’s okay — we’re problem solvers! Perhaps if we could drop down to the core native API, we could fill in a gap like this. Let’s start…
Async holes: StringContent
In a previous post, I introduced the concept of “async holes” — those unexpected gaps and obstacles when using asynchronous APIs in .NET. This time I will tell the tale of the async hole in StringContent. System.Net.Http.StringContent is the derived…
Async holes: ZipArchive
From time to time, I encounter unexpected gaps in asynchronous object models in .NET. I’ve taken to calling these “async holes” since they usually present an unpleasant obstacle in the clear path I try to follow while executing the TDD…
Tasks do scale (well enough)
I’ve said it before and I’ll say it again: threads don’t scale. But what about Tasks? Here is a simple application which spawns a large (configurable) amount of periodic background tasks: The tasks themselves are technically CPU bound, though they…
Async or non-blocking?
It is often helpful to distinguish between “truly async” code and merely “non-blocking” code. A program that dispatches long running operations to the thread pool would generally be non-blocking since it doesn’t tie up the calling thread. In contrast, a…
Efficient concurrency prevention
Sometimes you want asynchrony but not concurrency. For example, if you are writing data to a file, you should generally prefer asynchronous I/O, but you probably don’t want 10 other competing callers to corrupt the contents. Perhaps the simplest way…
Managed interop for native overlapped
Previously, I shared a basic sample for overlapped I/O with modern C++. I say “basic” but truth be told, there are multiple subtle aspects that one must be keenly aware of to avoid memory leaks or corruption. Thankfully, most of…
The wait is over: coroutines in C++
Long ago, I wrote about using the PPL to achieve a .NET 4.0 level of parity for async programming in C++. Since then, a lot of work has gone into raising this level of parity to .NET 4.5 and beyond.…
Oversubscribe now!
For small chunks of compute-bound work that must be offloaded to the background, you can choose from several APIs and patterns in .NET. In code written before .NET 4.0, you would probably use ThreadPool.QueueUserWorkItem. In modern day apps, you might…
Async pasts
When did asynchronous programming originate? I’m no historian, but one contender for the earliest roots of async would be Melvin Conway‘s coroutines. His 1963 paper “Design of a Separable Transition-Diagram Compiler” introduces coroutines and notes that they “can greatly simplify…