That depends on the details of WorkOnIt
. Do you use any means of synchronization for externally visible objects that you have to be careful. If not then you are safe.
For example if your WorkOnIt
looks like:
private void MyWorkOnIt(float[] input, int idx)
{
lock(input) { /* ... */ } // possible deadlock scenario
}
This could deadlock if the code that calls Execute
locks on the same object:
lock(myInput)
{
Execute(myInput, MyWorkOnIt);
}
In general I would try to make the delegates of parallel loops completely independent of any shared state. If I can't do - e.g. when I have to aggregate items - then I'll use one of the parallel loops which use a local state.