Lazy Initialization
During development, we will frequently use types that are resource-intensive for construction in terms of memory or computation time. So we might want to delay the construction of these types until we actually need them. This can be achieved by a new feature introduced in .NET framework 4.0, called Lazy Initialization. We can use this feature to improve the performance of our applications by delaying the instance construction of types.
Let's look at a sample window which is part of a contrived medical application. Let's create a WPF MVVM Light project, called MVVMAppLazyInitialization, in .NET Framework 4. In this sample, patients are selected and loaded, as shown in the following screenshot, so that their information can be ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access