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 ...

Get MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.