assume we have a lambda expression like
var thread= new Thread(() =>
{
Foo1();
Foo2(() =>
{
Foo3();
DoSomething();
}
);
});
the question is when DoSomething() evaluated? on thread creation or on calling thread.Start()?
DoSomething()may never be called. It will only be called ifFoo2()executes the delegate it’s given. So the order of execution is:Threadconstructor. None of the code in the delegate is executed.thread.Start().Foo1()executesFoo3()andDoSomething(), but those calls are not executed yetFoo2()Foo2()executes the delegate, thenFoo3()andDoSomething()will be executed