4

I'm using Task.Parallel class from the Microsoft Reactive Extensions (the .NET 3.5 library, not the ones from .NET 4, since my app is running on 3.5). Everything works fine on .NET, but when I run it in Mono (2.10.5, on Linux), it throws an exception when calling the Parallel.For() method:

System.Threading.Tasks.TaskSchedulerException: TaskSchedulerException_ctor_DefaultMessage 
 ---> System.EntryPointNotFoundException: SwitchToThread
 at (wrapper managed-to-native) System.Threading.Platform:SwitchToThread ()
 at System.Threading.Platform.Yield () [0x00000] in <filename unknown>:0
 at System.Threading.ManualResetEventSlim.Wait (Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0
 at System.Threading.ManualResetEventSlim.Wait () [0x00000] in <filename unknown>:0
 at System.Threading.Tasks.Task.InternalRunSynchronously (System.Threading.Tasks.TaskScheduler scheduler) [0x00000] in <filename unknown>:0
 --- End of inner exception stack trace ---
 at System.Threading.Tasks.Task.InternalRunSynchronously (System.Threading.Tasks.TaskScheduler scheduler) [0x00000] in <filename unknown>:0
 at System.Threading.Tasks.Task.RunSynchronously (System.Threading.Tasks.TaskScheduler scheduler) [0x00000] in <filename unknown>:0
 at System.Threading.Tasks.Parallel.ForWorker[Object] (Int32 fromInclusive, Int32 toExclusive, System.Threading.Tasks.ParallelOptions parallelOptions, System.Action`1 body, System.Action`2 bodyWithState, System.Func`4 bodyWithLocal, System.Func`1 localInit, System.Action`1 localFinally) [0x00000] in <filename unknown>:0

I couldn't find any resources on the Web covering this exception, so I'm kind of stuck. Any suggestions? Does Task Parallel library for 3.5 run at all on Mono?

Igor Brejc
  • 18,714
  • 13
  • 76
  • 95
  • 1
    Which version of the Reactive extensions library are you using? (If it is any consolation, and it is probably not relevant, but I installed the PFX library from here: http://nuget.org/packages/TaskParallelLibrary with the command Install-Package TaskParallelLibrary in VS on windows (so version 1.0.2856.0), built a simple Parallel.For console application then copied the exe and the DLL to a Mac running mono 2.10.9 and it ran fine). – kmp Apr 24 '12 at 16:51
  • @kmp: I'm using the same version, also through NuGet. It works without problems on my Linux Mint virtual machine, but breaks down on a netbook Linux Mint. Also breaks down on a user's Mac (also mono 2.10.9). I'll do some more testing using more and more complex Parallel.For loops and see how that goes. Thanks! – Igor Brejc Apr 25 '12 at 06:27
  • 1
    Having same problem with Unity3d in 2015 (not that suprising, since Unity just on principle won't be abreast of the times). Is there any solution? – Maxim Kamalov Nov 02 '15 at 21:38

0 Answers0