Let's say I have an method that calls another async method immediately or similar:
//Main method
public async Task<int> Foo1( int x )
{
var result = await DoingSomethingAsync(x );
return DoSomethingElse(result );
}
//other method
public async Task<int> Foo2( Double double )
{
return await Foo1( Convert.ToInt32(double ) );
}
Is there any specific reason that Foo2
needs/should have async/await, as opposed to simply calling:
//other method
public Task<int> Foo3( Double double )
{
return Foo1( Convert.ToInt32( double ) );
}
In a consumer, this would still be awaited, likeso, regardless of:
int x = await Foo1(1);
int x = await Foo2(1D);
int x = await Foo3(1D);
All those statements will compile. Will the compiler generate different IL for the two different methods?