Bug 3225 - Parallel.Invoke called with a single Action executes it twice
Summary: Parallel.Invoke called with a single Action executes it twice
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-02-04 11:28 UTC by Fabien GIGANTE
Modified: 2012-02-04 17:21 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Fabien GIGANTE 2012-02-04 11:28:03 UTC
Parallel.Invoke called with a single Action executes it twice.
I'm using 2.11 (master/88867d5 Fri Feb  3 22:21:23 CET 2012)

csharp> using System.Threading;
csharp> using System.Threading.Tasks;
csharp> Parallel.Invoke(()=>Console.WriteLine("Hello"));
Hello
Hello
csharp>
Comment 1 Fabien GIGANTE 2012-02-04 11:32:51 UTC
I suggest to replace the current code :

static void Invoke (Action[] actions, Func<Action, Task> taskCreator)
{
[...]
  if (actions.Length == 1 && actions[0] != null) actions[0] ();
[...]
}

By :

static void Invoke (Action[] actions, Func<Action, Task> taskCreator)
{
[...]
  if (actions.Length == 1 && actions[0] != null) { actions[0] (); return; }
[...]
}
Comment 2 Zoltan Varga 2012-02-04 17:21:19 UTC
Fixed in HEAD/2.10.