Question

Based on MSDN, we can using lazy initialization to defer the creation of a large or resource-intensive object, or the execution of a resource-intensive task, particularly when such creation or execution might not occur during the lifetime of the program.

To prepare for lazy initialization, you create an instance of Lazy. The type argument of the Lazy object that you create specifies the type of the object that you want to initialize lazily. The constructor that you use to create the Lazy object determines the characteristics of the initialization. Lazy initialization occurs the first time the Lazy.Value property is accessed.

Top description about Lazy tell me, that i should using it for initialization of massive objects and tasks. But as i know almost massiveness happened when i need to loading large data from a data storage.

At this position, i don't think Lazy be could any help to me.

Thus what's are attractive functinalities of Laziness initialization?

No correct solution

OTHER TIPS

The main benefit of using lazy objects is in the case where there is a fair chance you will never initialize them, the saving here is obvious. Another case would be to defer the computational cost - e.g. return the focus to the user in a UI application, and then do the actual initialisation as required, depending on the user actions, as long as the individual tasks are quick enough not to be noticed the user. The latter scenario might be optimised further, and make the initialisation run in background.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top