Summary
In this chapter, you considered some of the power and flexibility that concurrency provides. You started by passing target actions to tasks that you created and then looked at the static Task
factory helper methods. By using continuation tasks, you saw that single tasks and collections of tasks can be coordinated to perform aggregate actions.
Next, you studied the async
/await
keywords that can help you write simpler and more concise code that is, hopefully, easier to maintain.
This chapter looked at how C# provides, with relative ease, concurrency patterns that make it possible to leverage the power of multicore processors. This is great for offloading time-consuming calculations, but it does come at a price. You saw how the lock
statement can be used to safely prevent multiple threads from reading or writing to a value simultaneously.
In the next chapter, you will look at how Entity Framework and SQL Server can be used to interact with relational data in C# applications...