Sunday, January 23, 2011

Lazy Initialization in .NET 4

Lazy Initialization
AsyncLazy<T> : Lazy<Task<T>>

Classes
Lazy<T>
ThreadLocal<T> : IDisposable
static LazyInitializer

Lazy Constructor
Lazy<T>()
Lazy<T>(isThreadSafe)
Lazy<T>(valueFactory)
Lazy<T>(mode)
Lazy<T>(valueFactory, isThreadSafe)
Lazy<T>(valueFactory, mode)
Params: bool isThreadSafe, Func<T> valueFactory, LazyThreadSafetyMode mode

Delegates
Action delegates do not return a value
delegate void Action()
delegate void Action<in T>(T obj)
delegate void Action<in T1, in T2>(T1 arg1, T2 arg2)  //max params 16

delegate TResult Func<out TResult>()
delegate TResult Func<in T, out TResult>(T arg)
delegate TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2)  //max params 16

0 comments:

Post a Comment

Blog Archive