.NET Synchronisation APIs - Part 1 - In-Process Synchronisation
Introduction This is the first in a series of posts on .NET synchronisation. I will cover: In-process synchronisation (this post) Out-of-process synchronisation on the same machine Distributed synchronisation In .NET, in-process synchronisation mechanisms are used to restrict access to shared resources and manage concurrency in multi-threaded applications. The mechanisms I'm going to present on this post can be used only for in-proc code, for synchronising threads, meaning, they cannot be used to synchronise multiple processes, on the same or on different machines - I will write more posts on these subjects and link them here. Here I will be using the terms "locking" and "synchronising on" interchangeably, to mean the same thing. I won't go into too much theory, but thread synchronisation exists for preventing: Race conditions: two threads trying to modify the same data simultaneously Data corruption: data shared by two or more threads becomes inconsistent ...