.NET's Task libraries are powerful and handy, but they are easily abused. In particular, the thread pool provides no guaranteed execution ordering, which is critical for small, thread-safe state machines. I will show some abstractions (available in an open source library I wrote called Kts.Actors) that mitigate this issue. I'll also show some examples from MS's TPL Workflow package, which is similar. See https://github.com/BrannonKing/Kts.Actors

I'll also discuss a small state machine example. .NET's async/await push has brought us awaitable socket connections. However, users like to see it in a four-state perspective: disconnected, disconnecting, connecting, and connected. How can you transition between these in a thread-safe manner? [174]

Comments

Comments are closed.