If the “Shutter” component is not using all cores, that is not the cause of my system. I wrote a test in a script component and all resources are in use:
private void RunScript(List<int> steps, ref object result)
{
const int max_steps = 40;
var fibonaccis = new Fibonacci[steps.Count];
var counter = new CountdownEvent(steps.Count);
for (int i = 0; i < steps.Count; i++)
{
var n = steps[i];
if (n < 0) throw new Exception ("Steps must be >= 0.");
if (n > max_steps) throw new Exception ("Steps must be <= 40.");
var f = fibonaccis[i] = new Fibonacci ();
var state = new State { Steps = n, Counter = counter };
ThreadPool.QueueUserWorkItem(f.ThreadPoolCallback, state);
}
counter.Wait();
result = (from f in fibonaccis select f.Result).ToList();
}
// <Custom additional code>
class State
{
public int Steps;
public CountdownEvent Counter;
}
class Fibonacci
{
public int Result;
public void ThreadPoolCallback(Object state)
{
var tuple = (State) state;
Result = Calculate(tuple.Steps);
tuple.Counter.Signal();
}
public int Calculate(int n)
{
if (n <= 1)
return n;
return Calculate(n - 1) + Calculate(n - 2);
}
}
// </Custom additional code>