Reputation: 185
Is there an F# equivalent to the TPL Parallel.Invoke? So far, all i have come across is task factory for explicit task control but i am having problems profiling it.
Upvotes: 1
Views: 280
Reputation: 11525
What's wrong with using Parallel.Invoke
from F#? One of the best features of F# is that you can re-use all of the functionality available in the .NET Base Class Libraries (BCL).
To simplify things, I'd probably create a little function to map an array of F# functions into an array of Action
delegates, like this:
/// Wraps each F# in a System.Action delegate.
let funcsAsActions (funcs : (unit -> unit)[]) : System.Action[] =
funcs |> Array.map (fun f -> System.Action f)
Then, you can just pass the array returned by funcsAsActions
to Parallel.Invoke
.
Upvotes: 5