What’s the point of this blog post? In modern C#/.NET ecosystem there is encouragement to use async/await Task based asynchronous model over other asynchronous patterns and approaches. On the other side, there are still a lot of libraries (legacy, wrappers from other technologies/languages which uses events for callback calls, etc…) which use older EAP approach […]
Task-based Asynchronous Pattern (TAP) was introduced in .NET Framework 4 and since then, it is the recommended approach to asynchronous programming in .NET.
Event-based Asynchronous Pattern (EAP) is still in use, especially at legacy systems, but for new development is not recommended anymore.
In this post I will show how to wrap EAP into TAP and use more modern approach.
C# lock is mechanism to prevent concurrent access to “restricted” resource in multi-threaded environment. In multi-threaded applications locks are used to ensure that the current thread executes a block of code to completion without interruption by other threads. The lock statement obtains a mutual exclusion lock for a given object so that one thread executes […]