Processing Patterns

We can generally choose between event-driven processing, polling loops and timers. With loops it is important to implement a delay to prevent consuming a complete CPU when idle. For optimal reactivity such delays should be cancellable, ex by candellationToken.WaitHandle.WaitOne(someTimeSpan).

Event-driven processing. Generally preferred.

Polling loop in a dedicated thread. OK for a single worker loop.

Polling loop in tasks. With many worker loops use a task for each.

Poll using a timer. No need for a dedicated thread or task to prevent blocking the main thread.