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 if Foo2()
executes the delegate it's given. So the order of execution is:
Thread
constructor. None of the code in the delegate is executed.thread.Start()
.Foo1()
executesFoo3()
and DoSomething()
, but those calls are not executed yetFoo2()
Foo2()
executes the delegate, then Foo3()
and DoSomething()
will be executedIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With