C# Anonymous Thread with Lambda Syntax

() => ... just means that the lambda expression takes no parameters. Your example is equivalent to the following:

void worker()
{
    DoLongRunningWork();
    MessageBox.Show("Long Running Work Finished!");
}

// ...

new Thread(worker).Start();

The { ... } in the lambda let you use multiple statements in the lambda body, where ordinarily you’d only be allowed an expression.

This:

() => 1 + 2

Is equivalent to:

() => { return (1 + 2); }

Leave a Comment