public void Test() { int numTasks = 20; var state = new SharedState(); var tasks = new Task[numTasks]; for (int i = 0; i < numTasks; i++) { tasks[i] = Task.Run(() => new Job(state).DoTheJob()); } Task.WaitAll(tasks); WriteLine($"summarized {state.State}"); }
public Job(SharedState sharedState) { _sharedState = sharedState; }