Hello people I have a problem using parameters in threads. The problem is that I put an object List<object> as a parameter for a thread array in a foreach loop iterating a list of Lists (List<List<Object>>), and sometimes it duplicates the parameter (i already check that there is not a duplicate object before i put it in a thread). My code is something like this. Does anyone have an idea what is wrong?. Thanks in advance
foreach (List<object> list2 in list1) { threads[i] = new Thread(() =>DoWork(list2, nRetorno)); threads[i].Name = "thread " + i; threads[i].Start(); Thread.Sleep(5); i++; }
foreachand closures (same as duplicate).