使用多線程並行執行可以大大提高程序處理速度,但多個事務線程執行完畢後如何通知用戶呢?
可以使用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();

}