I was wondering if each loop execution could potentially be changing what was passed as the argument to the previous pool thread
No, the part of your code that is queuing up the task into the pool is synchronous
// here you are assigning the value that
// will be used as the state for the task when it is run
object param = list[i];
ThreadPool.QueueUserWorkItem(x => { MethodWithParameter(x); }, param);
So whatever the value of param
is at the point of the invocation of the method QueueUserWorkItem
will be passed as x
when the task starts
You could get into trouble doing something like this:
object param = null;
for (int i = 0; i < list.Count; i++)
{
//even though you are assigning a value to param here
//there is no telling when the task will actually execute
param = list[i];
ThreadPool.QueueUserWorkItem(x => { MethodWithParameter(param); }, null);
}
Because there is no telling what the value of param will be when the task is actually executed.