tags:

views:

167

answers:

4

let parallelTest n = Color(Color.DeepPink, Triangles(sphere n));;

Parallel.For(0,10,new Action(parallelTest));;

Error message : error FS0001: Type mismatch. Expecting a int -> unit but given a int -> scene. The type 'unit' does not match the type 'scene'

I'll glad if some body help me.

A: 

At which position does this error message occur? (I can't reproduce the error since I don't know the delcarations of some functions you use)

I guess the following: Parallel.For expects a int -> unit (Action<int> in standard .NET), but parallelTest has a different type (int -> scene) which is therefore incompatible.

And what are you trying to achieve with the whole code?

Dario
Hi Dario, thanks for your help, I'm trying to do surface subdvision in parallel, but I try to use this Parallel.For as a mean to make easy my job to do that version in parallel. Do you have any tips for me to do this easily and in parallel? Thanks again.
Angelica
+4  A: 

Compose your function with ignore to make it return unit:

Parallel.For(0, 10, parallelTest >> ignore)
Mauricio Scheffer
Hi Mauricio, thanks for your help too. It works!!!!!!! But now I need to know how can I return a scene type this for? Thanks again for your help.
Angelica
Parallel.For doesn't return any value. This might help you: http://weblogs.asp.net/podwysocki/archive/2009/02/23/adding-parallel-extensions-to-f.aspx . Create other questions if you have more doubts.
Mauricio Scheffer
+3  A: 

If you want 10 results, perhaps you want

[| for i in 0..9 do
       async { return parallelTest i } |]
|> Async.Parallel
|> Async.RunSynchronously

This will return an array of 10 scene results.

Brian
A: 

Thanks people for all! You're help me so much!! I'm glad for it! And Brian thanks, it works!!! I forget my OpenID, so I can't check this question with answered.

Angelica