Avatar

Use CancellationTokenSource In Batch Mode

#Lock Contention #CancellationTokenSource #Timer #.NET Framework #Multi-thread #xperf

The .NET platform provides many built-in synchronization primititves. Those primitives cover a broad range of application scenarios. On the down side, they could also lead to perfomrnace problems. The blog post from Geeks World provides an in depth discussion on the performance issues caused by some commonly used synchronization primitives.

In this post, I’d like to share some experience on the CancellationTokenSource from the performnace perspective.

Condition Variable in .NET Framework

#Condition Variable #.NET Framework #Multi-thread #Lock Contention

Motivation

As a C++ programmer coming to the C# world, the thing I miss the most when writing multi-threaded programs is condition variable.

I googled for a while trying to find a built-in counterpart or a crafted solution in .NET Framework. I failed. The top results returned were either wrong, or a design that lacked generalization.