I would like to know if there is a difference between these two async patterns. Obviously they will work. I would like to know if there is a hidden trap or performance overhead. What will happen with aggregateexception call stack in both cases?
//------Pattern1-------- PassThruMethod is awaiting
public async void EventHandler()
{
await PassThruMethod();
}
public async Task<int> PassThruMethod()
{
return await MyAsyncMethod();
}
public Task<int> MyAsyncMethod()
{
return Task.Run(() => 1);
}
//---Pattern2----- PassThruMethod is not awaiting
public async void EventHandler()
{
await PassThruMethod();
}
public Task<int> PassThruMethod()
{
return MyAsyncMethod();
}
public Task<int> MyAsyncMethod()
{
return Task.Run(() => 1);
}