Some good comments on my recent quiz. Many of you are hitting on the right thing…
The answer is no, this will not compile as is. This is because in V2.0 we added a new constructor to Thread that allows you to pass a ParameterizedThreadStart delegate.
Jay responded to the thread with several good fixes…
new Thread(delegate () { Console.WriteLine("On another thread"); }).Start();
new Thread((ParameterizedThreadStart) delegate { Console.WriteLine("On another thread"); }).Start();
new Thread(new ParameterizedThreadStart(delegate { Console.WriteLine("On another thread"); })).Start();
ParameterizedThreadStart start = delegate { Console.WriteLine("On another thread"); };
new Thread(start).Start();
new Thread(MyThreadStart).Start();
}
static void MyThreadStart(object obj)
{
Console.WriteLine("On another thread");
What do you think the “best” solution is? Clearly VS could be a little more helpful in writing this kind of code… what sort of VS support would you suggest?