Concurrent event driven programming does not work

Parallel or asynchronous* simultaneous program execution.
Our CPUs have multiple cores today, and we want to use them all, by running different computations in parallel oder by spawning a new thread and react, when it returns results.
Distributed Computing
It’s even harder, when concurrent processes run distributed over multiple machines.
Event Driven
A programming paradigm, where the program handles and reacts on events.
This is the basic concept of the entire MS-Windows operating system and of all technologies, that Microsoft provides for software development (and also Google / AngularJS goes into this direction).

*) I distinguish between async and parallel execution. To start a process (such as requesting a web page) asynchronously is like throwing a ball up in the air with one hand, and catch it with the other (when the web page is there). Parallel is more likely the picture of some horses on a gallop race course. Eg. when multiple threads in FuzzyDupes race in hunting for duplicate records over hours, accessing shared resources concurrently.


Events will happen in an undefined order, when code is executed asynchronously or in parallel. Event driven programming is therefore not suitable to operate concurrent program execution.

Solution 1: Futures / Promises

This offers a quick solution for async calls, but can’t help with parallel code.

Solution 2: State-Machines

They handle the transitions between states instead of events. This allows a reliable program execution even in indeterministic parallel executed program parts.

Async, parallel or distributed? The answer are State-Machines.

Detlef Kroll

  async .. await in C# is nothing else but a promise (sic!), but it lacks of some options. A better promise with error handling and Promise-Pipelining by method chaining can be found here.

  My favorite implementation of a State-Machine in C# can be found here.


We need State-Machines and a basic syntax (comparable to event handlers) in most programming languages, that deal with concurrency, very soon as a basic concept. This has to be implemented 100% thread-safe, because we want to use it for managing threads.

The word ‘Thread-Synchronization’ should be depreciated from the lexicon of computer science and should be replaced by the word ‘Transition’.

Many programming languages offer today some functions to start async threads or to run code in parallel, without extensions to deal with the heavy fundamental problems, that will arise by that. This can only lead to frustration when programmers believe, that they can do it so simple now.