doing await right by calling .ConfigureAwait(false)

This commit is contained in:
Brendan Forster
2013-10-31 12:06:46 +11:00
parent c22a9c874f
commit 43e82e124f
11 changed files with 28 additions and 28 deletions
+9 -9
View File
@@ -52,7 +52,7 @@ namespace Octokit
{
Ensure.ArgumentNotNull(uri, "uri");
var response = await Connection.GetAsync<T>(uri, parameters, null);
var response = await Connection.GetAsync<T>(uri, parameters, null).ConfigureAwait(false);
return response.BodyAsObject;
}
@@ -67,7 +67,7 @@ namespace Octokit
{
Ensure.ArgumentNotNull(uri, "uri");
var response = await Connection.GetHtml(uri, parameters);
var response = await Connection.GetHtml(uri, parameters).ConfigureAwait(false);
return response.Body;
}
@@ -109,7 +109,7 @@ namespace Octokit
{
Ensure.ArgumentNotNull(uri, "uri");
return _pagination.GetAllPages(async () => await GetPage<T>(uri, parameters, accepts));
return _pagination.GetAllPages(async () => await GetPage<T>(uri, parameters, accepts).ConfigureAwait(false));
}
/// <summary>
@@ -161,7 +161,7 @@ namespace Octokit
uri,
data,
accepts,
contentType);
contentType).ConfigureAwait(false);
return response.BodyAsObject;
}
@@ -178,7 +178,7 @@ namespace Octokit
Ensure.ArgumentNotNull(uri, "uri");
Ensure.ArgumentNotNull(data, "data");
var response = await Connection.PutAsync<T>(uri, data);
var response = await Connection.PutAsync<T>(uri, data).ConfigureAwait(false);
return response.BodyAsObject;
}
@@ -197,8 +197,8 @@ namespace Octokit
Ensure.ArgumentNotNull(uri, "uri");
Ensure.ArgumentNotNull(data, "data");
Ensure.ArgumentNotNullOrEmptyString(twoFactorAuthenticationCode, "twoFactorAuthenticationCode");
var response = await Connection.PutAsync<T>(uri, data, twoFactorAuthenticationCode);
var response = await Connection.PutAsync<T>(uri, data, twoFactorAuthenticationCode).ConfigureAwait(false);
return response.BodyAsObject;
}
@@ -216,7 +216,7 @@ namespace Octokit
Ensure.ArgumentNotNull(uri, "uri");
Ensure.ArgumentNotNull(data, "data");
var response = await Connection.PatchAsync<T>(uri, data);
var response = await Connection.PatchAsync<T>(uri, data).ConfigureAwait(false);
return response.BodyAsObject;
}
@@ -240,7 +240,7 @@ namespace Octokit
{
Ensure.ArgumentNotNull(uri, "uri");
var response = await Connection.GetAsync<List<T>>(uri, parameters, accepts);
var response = await Connection.GetAsync<List<T>>(uri, parameters, accepts).ConfigureAwait(false);
return new ReadOnlyPagedCollection<T>(
response,
nextPageUri => Connection.GetAsync<List<T>>(nextPageUri, parameters, accepts));
+3 -3
View File
@@ -260,7 +260,7 @@ namespace Octokit
async Task<IResponse<T>> Run<T>(IRequest request)
{
_jsonPipeline.SerializeRequest(request);
var response = await RunRequest<T>(request);
var response = await RunRequest<T>(request).ConfigureAwait(false);
_jsonPipeline.DeserializeResponse(response);
return response;
}
@@ -269,8 +269,8 @@ namespace Octokit
async Task<IResponse<T>> RunRequest<T>(IRequest request)
{
request.Headers.Add("User-Agent", UserAgent);
await _authenticator.Apply(request);
var response = await _httpClient.Send<T>(request);
await _authenticator.Apply(request).ConfigureAwait(false);
var response = await _httpClient.Send<T>(request).ConfigureAwait(false);
ApiInfoParser.ParseApiHttpHeaders(response);
HandleErrors(response);
return response;
+3 -3
View File
@@ -33,8 +33,8 @@ namespace Octokit.Internal
using (var requestMessage = BuildRequestMessage(request))
{
// Make the request
var responseMessage = await http.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead);
return await BuildResponse<T>(responseMessage);
var responseMessage = await http.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
return await BuildResponse<T>(responseMessage).ConfigureAwait(false);
}
}
@@ -48,7 +48,7 @@ namespace Octokit.Internal
{
if (content != null)
{
responseBody = await responseMessage.Content.ReadAsStringAsync();
responseBody = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
contentType = GetContentType(content);
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Octokit.Internal
var nextPageUrl = _info.GetNextPageUrl();
if (nextPageUrl == null) return null;
var response = await _nextPageFunc(nextPageUrl);
var response = await _nextPageFunc(nextPageUrl).ConfigureAwait(false);
return new ReadOnlyPagedCollection<T>(response, _nextPageFunc);
}
}