What to use to wait on a indeterminate number of tasks?
Posted
by Scott Chamberlain
on Stack Overflow
See other posts from Stack Overflow
or by Scott Chamberlain
Published on 2010-06-15T19:58:28Z
Indexed on
2010/06/15
20:12 UTC
Read the original article
Hit count: 189
I am still fairly new to parallel computing so I am not too sure which tool to use for the job.
I have a System.Threading.Tasks.Task
that needs to wait for n number number of tasks to finish before starting. The tricky part is some of its dependencies may start after this task starts (You are guaranteed to never hit 0 dependent tasks until they are all done).
Here is kind of what is happening
- Parent thread creates somewhere between 1 and (NUMBER_OF_CPU_CORES - 1) tasks.
- Parent thread creates task to be run when all of the worker tasks are finished.
- Parent thread creates a monitoring thread
- Monitoring thread may kill a worker task or spawn a new task depending on load.
I can figure out everything up to step 4. How do I get the task from step 2 to wait to run until any new worker threads created in step 4 finish?
© Stack Overflow or respective owner