Trying to pass function instead lambda expression and finally mixed up why line:
int t2 = await Task.Run( ()=>Allocate2() );
not raises error. This lambda expression ()=>Allocate2() not returns Task. Why no error?
How to create task without lambda expression with function Allocate?
static async void Example()
{
int t = await Task.Run(Allocate);
int t2 = await Task.Run( ()=>Allocate2() );
Console.WriteLine("Compute: " + t);
}
static Task<int> Allocate()
{
return 1;
}
static int Allocate2()
{
return 1;
}