If I have this:
public string DoSomething(string arg)
{
string someVar = arg;
DoStuffThatMightTakeAWhile();
return SomeControl.Invoke(new Func<
As said, each thread hitting DoSomething is creating a separate someVar on its stack, and therefore no thread has any effect on another's someVar.
It is worth noting though, that if a local is captured in a closure and there is multi-threading initiated in that scope, that this can indeed cause different threads to affect the values each other sees, even in the case of value types (which we would normally think of as not something that another method can affect - in this way closures are not like class methods:
public static void Main(string[] args)
{
int x = 0;
new Thread(() => {while(x != 100){Console.WriteLine(x);}}).Start();
for(int i = 0; i != 100; ++i)
{
x = i;
Thread.Sleep(10);
}
x = 100;
Console.ReadLine();
}
Demonstrates this.