I have following methods which are working fine for me:
1.This is using "async await" approach:
public async Task AddClients(string clientId)
{
bool isAlreadyAdded = await CheckIsClientExists(clientId);
if(isAlreadyAdded)
{
await AddNewClientToGroup(clientId);
}
}
2.This is method is using GetAwaiter() approach:
public async Task AddClients(string clientId)
{
bool isAlreadyAdded = await CheckIsClientExists(clientId);
if(isAlreadyAdded)
{
AddNewClientToGroup(clientId).GetAwaiter().GetResult();
}
}
I have seen the link : Async await vs GetAwaiter().GetResult() and callback . And this have not explained why and how GetAwaiter() leads to a deadlock situation.
Can anyone explain the difference between the both approaches, i.e await and GetAwaiter()?