AsParallel MonoTouch application crash

MonoTouch advertises support AsParallelon its website with this piece of code:

from item in items.AsParallel ()
   let result = DoExpensiveWork (item)
   select result;

However, even a trivial pattern resets my application:

 var items = new [] { 1, 2, 3 };
 var twice = (
        from x in items.AsParallel()
        select 2 * x
    ).ToArray();

System.ExecutionEngineException has been thrown.  Attempting to JIT compile method 'System.Linq.Parallel.QueryNodes.WrapHelper: <Wrap <code> 1> m__4A <int> (System.Collections.Generic.IEnumerator </code> 1 <int>)' while running with - aot-only.

I know that MonoTouch cannot handle virtual generic methods, but does PLINQ not work?
What am I doing wrong?

MonoTouch version is 5.3.5.

The same goes for Parallel.ForEach:

System.AggregateException: One or more errors occured ---> System.Exception:
Attempting to JIT compile method 'System.Threading.Tasks.Parallel:<ForEach`1>m__36<int> ()' while running with --aot-only.
See http://docs.xamarin.com/ios/about/limitations for more information.
+5
source share
1 answer

This is a well-known limitation in MonoTouch and generics - in this case, it is due to the fact that you work with structures.

It should work if you use objects instead:

var items = new object [] { 1, 2, 3 };
var twice = (
    from x in items.AsParallel()
    select 2 * x
).ToArray();

, , , , .

+4

All Articles