Wednesday, May 19, 2010

Lazy, lazy, lazy… Nope, not me, we’re talking System.Lazy

Derik Whittaker - Getting Lazy with System.Lazy

“One of the pretty cool new nuggets inside the .Net 4.0 framework is System.Lazy and System.Lazy<T>.  What System.Lazy brings to the table is a way to create objects which may need to perform intensive operations and defer the execution of the operation until it is 100% absolutely needed.

Lets take a look at how to use the System.Lazy type.

To better convey how to use this type we should first create some context.  In our example (trivial i know) we will have an orders factory which creates orders.  Take a look at the code below.

image …”

There are some .Net namespaces that just cry out for additional R&D time. I mean, how can you not want to dig into System.Lazy?  ;)

 

Related Past Post XRef:
Think .Net Cache = System.Web.Caching? .Net 4 has a present for you, System.Runtime.Caching.
A trip down the .Net 4 System.Xml path, some pitfalls and how you can avoid them
Interesting .Net 4 thing of the day: String.IsNullOrWhiteSpace()

.Net 4 Client Profile/Full silent install/repair/uninstall command line options

Changing your target to .Net 4 – What’s changed from .Net 3.5 SP1 and what you can do about it as you move to .Net 4
Some VS2010/.Net4 and related Training Kits (to give you something to download until VS2010 is available)
What’s New in Visual Studio 2010 & .Net 4 – The Official MSDN Source
Deep Zoom the .Net Framework 4 Poster

No comments: