Task-Based Asynchronous Pattern (TAP)
April 29, 2020
Returns Task or Task<TResult> Use Async suffix in methods Overloaded to accept cancelation token
Tips & Thoughts
April 29, 2020
Returns Task or Task<TResult> Use Async suffix in methods Overloaded to accept cancelation token
April 29, 2020
The task parallel library (TPL) is a set of public types and APIs.The vision behind the TPL is for the developers to be able to maximize the performance of code while not having to worry about the nitty gritties of threading. TPL makes us productive by Simplifying the process of adding parallelism and concurrency to applications. Scaling the degree of concurrency dynamically. Handling partitioning of the work . Scheduling threads…
April 28, 2020
.NET Framework built-in static methods are thread safe.When creating static methods, it is a best practice to make them thread safe. Thread Affinity Thread that instantiate an object is the only thread that is allowed to access its members. (Like WPF UI thread)One of the advantages of having thread affinity is that we may not need to use a lock to use instantiated object, since no other thread can access…
April 27, 2020
Exclusive Locks lock(someObject){}Allow only one thread to access a certain section of code. unless and until the thread has not finished executing that code, no other thread will be able to enter.Alternative is to use Monitor.Enter/Monitor.Exit it’s only syntactical difference. behind the scenes, they have the same exact implementation. Two types of exclusive locks Lock Mutex If we give a name to a mutex , that mutex would be accessible…
April 27, 2020
Threads are the most low-level constructs when it comes to multithreading. However work with threads could be very challenging. Let’s say I need a sudden value from worker thread return back to the main thread, the only way is using Join and another variable to retrieve value.. It works, but it can get complicated. So tasks come to our rescue. Task is a higher level abstraction and they’re capable of…