2 tasks running in parallel, but one finishes work and waits for the other to complete -


this extension solution in 2 async tasks in parallel , waiting results - .net

the methods of 2 tasks are:

private sub tempworker1()   = 1 50000      if mod 100 = 0         console.writeline("from 1:{0}", i)      end if   next end sub  private sub tempworker2()   = 1 1000      if mod 100 = 0         console.writeline("from 2:{0}", i)      end if   next end sub 

the calling methods are:

dim task1 task = task.run(addressof tempworker1) dim task2 task = task.run(addressof tempworker2) await task.whenall(task1, task2).configureawait(false) 

now, i'd need have task1 , task2 run in parallel task1 should not on until task2 complete. , entire process should wait both tasks complete.

is there way achieve using tpl. or need bank on global variables stop task1 finishing until task2 sets global variable?

i aware of continuewith defeat parallelism tasks running 1 after other - not requirement.

i'd need have task1 , task2 run in parallel task1 should not on until task2 complete.

so, start task2 first, pass task2 tempworker1:

dim task2 task = task.run(addressof tempworker2) dim task1 task = task.run(function() tempworker1(task2)) 

and have tempworker1 call await task2 when needs value.


Comments