public async Task <string> AwaitDirectly() { var result1 = await _api.CallAsync("one"); var result2 = await _api.CallAsync("two"); var result3 = await _api.CallAsync("three"); return($"Await directly results: {string.Join(", ", result1, result2, result3)}"); }
public async Task <string> Pitfall1() { try { var result = await _api.CallAsync(); return($"Got this on first try: {result}"); } catch (Exception) { Thread.Sleep(1000); var result = await _api.CallAsync(); return($"It failed, got it on second try: {result}"); } }
public string HelloSyncOverAsync() { var result = _api.CallAsync().Result; return(result); }