我沒有什麼問題。循環的不同行爲
我的輸入: 配置 - 包含此刻2個不同對象的集合。
結果看起來就像被執行了兩次,但具有相同參數。如果在循環內部放置斷點,我會看到不同的對象。我做錯了什麼?
List<Thread> threads = new List<Thread>();
foreach (var configuration in configurations)
{
Thread thread = new Thread(() => new DieToolRepo().UpdateDieTool(configuration));
thread.Start();
threads.Add(thread);
}
threads.WaitAll();
我有什麼:
你對「結果看起來像執行了兩次,但具有相同的參數」是什麼意思? 請向我們展示整個代碼和您的預期/實際輸出。此外,粘貼代碼而不是放置圖像 –
由於@NahuelIanni問,請顯示代碼爲'DieToolRepo' –