Main( ( item Product p = id = Id { ; Title { ; IList<Lazy<Product>><Product> product1 = Lazy<Product>(() => Product() { Id = , Title = <Product> product2 = Lazy<Product>(() => Product() { Id = , Title = <Product> product3 = Lazy<Product>(() => Product() { Id = , Title = List<Lazy<Product>> IList<Product>= Product() { Id = , Title = = Product() { Id = , Title = = Product() { Id = , Title = List<Product>
In another case, we know that data synchronization is required for the single-piece design mode in the case of multithreading:
Singleton _Instance =
In this way, we can ensure that there is only one instance in the case of multithreading, because it is the initialization object during program loading, but also because of this, it loses the advantage of a single piece and loads as needed.
Therefore, we can achieve this:
Lazy<SingletonLazy> _Instance = Lazy<SingletonLazy>
In this way, you can ensure that there is an instance, and at the same time implement delayed loading, load as needed.
The above content has been introduced. You are welcome to discuss and correct it.
Appendix:
Reference: http://www.codeproject.com/Articles/612801/Lazy-Object-Initialization-with-System-Lazy-of-T-c
Demo download: http://files.cnblogs.com/wpfworld/LazyLoadDemo.rar