Cached property vs Lazy

后端 未结 7 1338

In .NET 4 the following snippet with a cached property can also be written using the System.Lazy class. I measured the performance of both approaches and it\'s pret

7条回答
  •  误落风尘
    2020-12-04 13:31

    Lazy will correctly handel concurrent scenarios (if you pass in the correct LazyThreadSafetyMode ) while your example does not have any thread-safety checks.

提交回复
热议问题