Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Completion of an Array of Threads

I have created an array of threads and started all of them. How to know whether all threads have completed work. I don't want to use thread.wait or thread.join.

like image 396
Harsha Avatar asked May 14 '10 11:05

Harsha


1 Answers

If you are using .NET 4 you could use the Task Parallel Library and the ContinueWhenAll method.

You'd have to modify your threads to be represented as Task's. Tasks are easier to work with then threads. Usually you do not have to worry about lower-level things as you are forced to do now like scheduling or waiting for things to complete.

like image 50
Ronald Wildenberg Avatar answered Sep 22 '22 02:09

Ronald Wildenberg