I wrote the code below,
Task.Factory.StartNew<int>(async () =>
{
await Task.Delay(1000);
return 42;
});
but the read line appeared under the “async” keyword, and the code cannot compiled due to some syntax error, can anybody advise me what to do?
Thx a lot!
You probably want to use
Task.Run, which has more natural syntax forasynclambdas: