如何将字典作为参数传递给线程函数,然后遍历它?
Dictionary<string, Track> dic = allTracks;
updateThread = new Thread(() => toDB(dic));
updateThread.Start();
和功能:
public static void toDB( Dictionary<string, Track> dict)
{
foreach (KeyValuePair<string, Track> pair in dict)
{
//do something - but I do not alter anything in dictionary
}
}
我试过这样,但我得到一个错误
收藏已修改;枚举操作可能无法执行。