Async : IProgress and Immutability

In the previous post, we explored IProgress interface briefly and understood how it helps us in reporting progress. It seemed a perfect fit choice, with little chances of human errors. However, there are things one needs to be aware of to ensure you do not end up with unrecognizable errors. Let's rewrite the code in … Continue reading Async : IProgress and Immutability

Reporting Progress in Async Method

Quite often you would need to provide some kind of progress from your long running asynchronous method, especially if it process multiple activities. Though there might be multiple ways to achieve it, Microsoft provides us with a simple and efficient interface IProgress, which enables us to achieve the result. Let's hit the code straightaway. The … Continue reading Reporting Progress in Async Method

Unit Testing Asynchronous Code

Unit Testing Asynchronous methods in older days were pretty tough, but thanks to the advances made in the Unit Testing Frameworks, this is now all the more easier. We will begin by writing an async method, which we could use for writing our Unit Tests against. The advancements in Unit Testing Framework has made it … Continue reading Unit Testing Asynchronous Code

WaitForFirstN Tasks Method

There is a definite gap between TAP Utilities Task.WaitAny and Task.WaitAll. How do we wait for the first 'N' tasks from an array of tasks. That is one utility that is missing from TAP's rich repository. It might not be hard to implement one by yourself though. The above code uses existing Task Collaborators Task.WaitAny … Continue reading WaitForFirstN Tasks Method

Switching Context With Async

Whenever an await is encountered in the code, a context is captured, which is later used when the promise is completed and ready to continue. If the method is called by the UI thread, usually, the context could be UI context, unless the awaited method itself creates a new thread. This can be demonstrated in … Continue reading Switching Context With Async