Hi
I might be missing something extremely obvious here but given the following:-
Public Lazy(bool isThreadSafe)
The write up for this is
true to make this instance usable concurrently by multiple threads; false to make the instance usable by only one thread at a time.
I cannot see any logic to determine what would happen if true was set or if false was set?
Regards
Steven
Loading
VulpesPosted Jul 21, 2012, 11:44 AM
When you have a generic class such as Lazy
public Lazy(Func
Guest UserPosted Jul 21, 2012, 6:49 AM
When you say internal to the constructor are you implying that the constructor would have some conditional logic to determine the correct Enum to use depending whether true or false.
When it comes to usage of Lazy
Regards
Steven
VulpesPosted Jul 20, 2012, 12:07 PM
According to the MSDN docs, if it's passed a value of true, then its thread safety mode is:
LazyThreadSafetyMode.ExecutionAndPublication
but, if it's passed a value of false, then its thread safety mode is:
LazyThreadSafetyMode.None
For what these values mean, I'd check out:
http://msdn.microsoft.com/en-us/library/system.threading.lazythreadsafetymode.aspx
Of course it's up to you to pass the appropriate argument to the constructor depending on whether you need it to be thread-safe when accessed by multiple threads or not.