0
說我的主線程調用一個循環,該循環會創建新線程並在某些其他函數上啓動它們。我如何確保在所有線程完成執行後執行語句
for (int i = 0; i < numberOfThreads; i++)
{
Thread thread = new Thread(start);
thread.Start();
}
call_This_Function_After_All_Threads_Have_Completed_Execution();
我如何確保我的方法在所有其他線程完成執行後才被調用。
['Task'(HTTP: //msdn.microsoft.com/en-us/library/system.threading.tasks.task.aspx)將使您的生活更輕鬆。 :) – Leri
看看這篇文章:http://stackoverflow.com/questions/1584062/how-to-wait-for-thread-to-finish-with-net – JohnLBevan