Both are delegates and have the same signature, but I can not use Action as ThreadStart.
Why?
Action doIt;
doIt = () => MyMethod("test");
Thread t;
t = new Thread(doIt);
t.Start();
but this seems to work:
Thread t;
t = new Thread(() => MyMethod("test"));
t.Start();
Because thread start is a separate delegate type and Action
cannot be converted to ThreadStart
.
This case works because here your lambda is treated by compiler as ThreadStart:
Thread t;
t = new Thread(() => MyMethod("test"));
t.Start();
If 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