1

In the following scenario: can we block the main thread to begin to perform step 3 until step 2 finished?
I'm talking about C#

//step 1: some tasks
/*
*/

//step 2: perform some sub tasks in parallel.
Parallel.ForEach(X, x => Foo(x));

//step 3: Some other task
//Can we begin to perform step 3 until all sub tasks in step 2 finished???
dingx
  • 1,621
  • 3
  • 20
  • 38

2 Answers2

1

That should be the default behaviour. Put it in a console app with a console.writeline after it to prove it if you need to.

kidshaw
  • 3,423
  • 2
  • 16
  • 28
0

If you are using Task class to create the "tasks" you mentioned, probably try Task.WaitAll(Task[])

slepox
  • 792
  • 4
  • 9