In the last chapter, we discussed thread-safe concurrent collections in C#. Concurrent collections help to improve the performance of parallel code without having a developer worry about synchronization overheads.
In this chapter, we will discuss some more concepts that help to improve the performance of code, both using custom implementations as well as using built-in constructs. Here are the topics we are going to discuss during this chapter:
- Introduction to lazy initialization concepts
- Introduction to System.Lazy<T>
- How to handle exceptions with the lazy pattern
- Lazy initialization with thread-local storage
- Reducing the overhead with lazy initializations
Let's get started by introducing the lazy initialization pattern.