I am trying to create a thread and add it in a list of Threads:
int j = 0;
while(j!=6)
{
Thread th = new Thread(() => SaveImages(L104List[j], folderFilePath, bw));
ThreadList.Add(th);
j++;
//th.Start();
}
but it is not exiting when j becomes 6. So it throws a s exception:
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
BUT, whenever I try to use breakpoints to manually iterate the loop, it exits and goes to the next statements of code. Why is it doing that?
PS. I also tried for loop, and it also does that.
L104Listmight be less than 6 item in the collection.L104List.Lenght > jbe the condition?