Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Threading.Lazy{T}"/> class
 /// that uses a specified initialization function and a specified thread-safety mode.
 /// </summary>
 /// <param name="valueFactory">
 /// The <see cref="T:System.Func{T}"/> invoked to produce the lazily-initialized value when it is needed.
 /// </param>
 /// <param name="isThreadSafe">true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.
 /// </param>
 /// <exception cref="System.ArgumentNullException"><paramref name="valueFactory"/> is
 /// a null reference (Nothing in Visual Basic).</exception>
 public Lazy(Func <T> valueFactory, bool isThreadSafe) :
     this(valueFactory, LazyHelper.GetModeFromIsThreadSafe(isThreadSafe), useDefaultConstructor : false)
 {
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Threading.Lazy{T}"/>
 /// class that uses <typeparamref name="T"/>'s default constructor and a specified thread-safety mode.
 /// </summary>
 /// <param name="isThreadSafe">true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.
 /// </param>
 public Lazy(bool isThreadSafe) :
     this(null, LazyHelper.GetModeFromIsThreadSafe(isThreadSafe), useDefaultConstructor : true)
 {
 }