Summary
In short, mobile applications should not be designed to undertake long-running tasks on the user interaction tier, but rather use asynchronous mechanisms to execute these workflows. The UI, in this case, would just be responsible for keeping the user informed about the background execution status. While in the past, background tasks were handled through the classic .NET threading model, nowadays, the TAP model provides a rich set of functionalities, which releases developers from the burden of creating, managing, and synchronizing threads and thread pools. In this chapter, we have seen that there are various patterns that can help us create background tasks. These would then yield back to the UI thread so that the asynchronous process results can be propagated to the UI. We also discussed different strategies for synchronous mechanisms, together with Tasks, thus avoiding deadlocks and race conditions. Additionally, we looked into the native background procedures on iOS and...