private void showStatistics(string path)
{
Thread thread = new Thread(() =>
{
Statistics myClass= new Statistics(path);
list = myClass.getStatistics();
});
thread.Start();
foreach (KeyValuePair<string, string> item in list)
{
listBoxIps.Items.Add(item.Key + item.Value + "\n");
}
}
我想等到線程完成自己的工作,然後啓動foreach
,當我把foreach
在線程,收十字線程錯誤。如何要等到我的線程完成
另外,看看並理解Form.Invoke。你可以讓你的線程在完成時調用窗體中的一個方法,但是它必須使用Invoke來執行......如果你的'後線程邏輯'對任何控件做任何事情。 – sethcall 2012-03-10 16:54:02
感謝其與BackgroundWorker的良好合作 – user979033 2012-03-10 17:04:51