LazyInitMode.AllowMultipleExecutionAbout a month ago there was a post on the PFX blog <a href="http://blogs.msdn.com/pfxteam/archive/2009/04/03/9529966.aspx">Do you use LazyInitMode.AllowMultipleExecution?</a><br/><br/>As suggested in that Post, I also think this mode has little use. It will allow multiple threads to execute and thereby prevent them from beeing blockd. But if I have the choice between blocking a thread or having two threads do the same thing and throw away the result of one of them I will always choose to block. Waiting in my opinion is not a bad thing if there is nothing usefull to do.<br/><br/>I also noticed that in Beta 1 this option has been renamed into <span style="font-family:Consolas;font-size:x-small">AllowMultipleThreadSafeExecution</span><br/><br/>While this name does state what it does I do think it can be confusing. A developer new to this API might think that A<span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">llowMultipleThreadSafeExecution </span></span>will be 'safer' then <span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">EnsureSingleThreadSafeExecution</span></span>. As it suggests that the first is even thread safe when using multiple threads, but the latter is only safe when there is just one thread.<br/><br/>So if you ask me (and you did) I would drop this option, if only it were to prevent developers to use it by mistake. Another option would be to create two searate switches, one for ThreadSafety, and one for multiple execution. In any case it shoud be made more clear than it is now that  <span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">NotThreadSafe and <span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">EnsureSingleThreadSafeExecution </span></span></span></span>are the preferred options (depending on the scenario ofcourse).© 2009 Microsoft Corporation. All rights reserved.Tue, 16 Jun 2009 02:11:24 Zefdf5f0d-777a-4340-ac8c-7c871e644205http://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/efdf5f0d-777a-4340-ac8c-7c871e644205#efdf5f0d-777a-4340-ac8c-7c871e644205http://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/efdf5f0d-777a-4340-ac8c-7c871e644205#efdf5f0d-777a-4340-ac8c-7c871e644205Frank Bakkerhttp://social.msdn.microsoft.com/Profile/en-US/?user=Frank%20BakkerLazyInitMode.AllowMultipleExecutionAbout a month ago there was a post on the PFX blog <a href="http://blogs.msdn.com/pfxteam/archive/2009/04/03/9529966.aspx">Do you use LazyInitMode.AllowMultipleExecution?</a><br/><br/>As suggested in that Post, I also think this mode has little use. It will allow multiple threads to execute and thereby prevent them from beeing blockd. But if I have the choice between blocking a thread or having two threads do the same thing and throw away the result of one of them I will always choose to block. Waiting in my opinion is not a bad thing if there is nothing usefull to do.<br/><br/>I also noticed that in Beta 1 this option has been renamed into <span style="font-family:Consolas;font-size:x-small">AllowMultipleThreadSafeExecution</span><br/><br/>While this name does state what it does I do think it can be confusing. A developer new to this API might think that A<span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">llowMultipleThreadSafeExecution </span></span>will be 'safer' then <span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">EnsureSingleThreadSafeExecution</span></span>. As it suggests that the first is even thread safe when using multiple threads, but the latter is only safe when there is just one thread.<br/><br/>So if you ask me (and you did) I would drop this option, if only it were to prevent developers to use it by mistake. Another option would be to create two searate switches, one for ThreadSafety, and one for multiple execution. In any case it shoud be made more clear than it is now that  <span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">NotThreadSafe and <span style="font-family:Consolas;font-size:x-small"><span style="font-family:Consolas;font-size:x-small">EnsureSingleThreadSafeExecution </span></span></span></span>are the preferred options (depending on the scenario ofcourse).Sun, 14 Jun 2009 05:47:44 Z2009-06-16T02:11:24Zhttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/efdf5f0d-777a-4340-ac8c-7c871e644205#43805c5f-f881-40e3-9b5c-22b1497314achttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/efdf5f0d-777a-4340-ac8c-7c871e644205#43805c5f-f881-40e3-9b5c-22b1497314acMiha Markichttp://social.msdn.microsoft.com/Profile/en-US/?user=Miha%20MarkicLazyInitMode.AllowMultipleExecutionHi Frank,<br/> <br/> &quot;As suggested in that Post, I also think this mode has little use. It will allow multiple threads to execute and thereby prevent them from beeing blockd. But if I have the choice between blocking a thread or having two threads do the same thing and throw away the result of one of them I will always choose to block. Waiting in my opinion is not a bad thing if there is nothing usefull to do.&quot;<br/> <br/> Well, the performance issue is that when blocking it is always blocking, not just for the first time. So, if you have many access to the instance you might loose time.<br/> As opposite to non-blocking mode when the possible hit is only if/when two or more threads access the variable for the first time. I see the benefits of this second mode as the &quot;bad&quot; scenario might even not happen at all and after that you have no peformance issues anymore.<hr class="sig">Miha Markic [MVP C#] http://blog.rthand.comSun, 14 Jun 2009 08:05:10 Z2009-06-14T08:05:10Zhttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/efdf5f0d-777a-4340-ac8c-7c871e644205#a84bc034-7dac-4480-88fc-fabd22708e9fhttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/efdf5f0d-777a-4340-ac8c-7c871e644205#a84bc034-7dac-4480-88fc-fabd22708e9fJosh Phillipshttp://social.msdn.microsoft.com/Profile/en-US/?user=Josh%20%20PhillipsLazyInitMode.AllowMultipleExecutionFrank, <div><br/></div> <div>Thanks for the feedback!  We will definitely take it into account.  The bit about the naming is particularly helpful.</div> <div><br/></div> <div>Thanks,</div> <div><br/></div> <div>Josh</div>Mon, 15 Jun 2009 16:46:07 Z2009-06-15T16:46:07Z