可以使用Join將多個事務線程合並到主線程中,事務線程執行完畢後主線程才可以繼續執行。代碼如下:
for (int i = 0; i < matchCollection.Count; i++ )
...{
//Start new thread
thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(ThreadMethod));
thread.Start(remotingUrl);
threadList.Add(thread);
}
foreach (System.Threading.Thread Thread in threadList)
...{
Thread.Join();
}