Example #1
0
        static void Main()
        {
            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}");
        }
        static void Main()
        {
            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}");

        }
Example #3
0
 public Job(SharedState sharedState)
 {
     _sharedState = sharedState;
 }