Skip to content

Commit ce4a399

Browse files
govorovvsChoc13
authored andcommitted
Add ConfigureAwait(false) to all task awaitings (#22) (#23)
1 parent fcb078b commit ce4a399

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/Winton.Extensions.Configuration.Consul/ConsulConfigurationClient.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public ConsulConfigurationClient(IConsulClientFactory consulClientFactory, ICons
2828

2929
public async Task<IConfigQueryResult> GetConfig()
3030
{
31-
var result = await GetKVPair();
31+
var result = await GetKVPair().ConfigureAwait(false);
3232
UpdateLastIndex(result);
3333
return new ConfigQueryResult(result);
3434
}
@@ -43,7 +43,8 @@ private async Task<QueryResult<KVPair>> GetKVPair(QueryOptions queryOptions = nu
4343
{
4444
using (IConsulClient consulClient = _consulClientFactory.Create())
4545
{
46-
QueryResult<KVPair> result = await consulClient.KV.Get(_source.Key, queryOptions, _source.CancellationToken);
46+
QueryResult<KVPair> result = await consulClient.KV.Get(_source.Key, queryOptions, _source.CancellationToken)
47+
.ConfigureAwait(false);
4748
switch (result.StatusCode)
4849
{
4950
case HttpStatusCode.OK:
@@ -61,7 +62,7 @@ private async Task PollForChanges(Action<ConsulWatchExceptionContext> onExceptio
6162
{
6263
try
6364
{
64-
if (await HasValueChanged())
65+
if (await HasValueChanged().ConfigureAwait(false))
6566
{
6667
var previousToken = Interlocked.Exchange(ref _reloadToken, new ConfigurationReloadToken());
6768
previousToken.OnReload();
@@ -84,7 +85,7 @@ private async Task<bool> HasValueChanged()
8485
queryOptions = new QueryOptions { WaitIndex = _lastIndex };
8586
}
8687

87-
var result = await GetKVPair(queryOptions);
88+
var result = await GetKVPair(queryOptions).ConfigureAwait(false);
8889
return result != null && UpdateLastIndex(result);
8990
}
9091

src/Winton.Extensions.Configuration.Consul/ConsulConfigurationProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ConsulConfigurationProvider(IConsulConfigurationSource source, IConsulCon
3131
() => _consulConfigClient.Watch(_source.OnWatchException),
3232
async () =>
3333
{
34-
await DoLoad(reloading: true);
34+
await DoLoad(reloading: true).ConfigureAwait(false);
3535
OnReload();
3636
});
3737
}
@@ -53,7 +53,7 @@ private async Task DoLoad(bool reloading)
5353
{
5454
try
5555
{
56-
IConfigQueryResult configQueryResult = await _consulConfigClient.GetConfig();
56+
IConfigQueryResult configQueryResult = await _consulConfigClient.GetConfig().ConfigureAwait(false);
5757
if (!configQueryResult.Exists && !_source.Optional)
5858
{
5959
if (!reloading)

0 commit comments

Comments
 (0)