Skip to content

Commit

Permalink
Turn ConfigureAwait(true) into ConfigureAwait(false).
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuai Zhang committed Dec 21, 2019
1 parent 6ebd4aa commit 4a088bc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public async Task StopAsync()
}

this.cancellationTokenSource.Cancel();
await this.backgroundTask.ConfigureAwait(true);
await this.backgroundTask.ConfigureAwait(false);
this.client.Close();

this.backgroundTask.Dispose();
Expand All @@ -133,7 +133,7 @@ protected virtual void Dispose(bool disposing)
{
if (this.backgroundTask != null)
{
this.StopAsync().ConfigureAwait(true).GetAwaiter().GetResult();
this.StopAsync().GetAwaiter().GetResult();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
this.Close().ConfigureAwait(true).GetAwaiter().GetResult();
this.Close().GetAwaiter().GetResult();

this.sendingBackgroundTask.Dispose();
this.receivingBackgroundTask.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<PlcClient> AcceptAsync()
{
TcpClient tcpClient = await this.tcpListener
.AcceptTcpClientAsync()
.ConfigureAwait(true);
.ConfigureAwait(false);
return new PlcClient(this.loggerFactory.CreateLogger<PlcClient>(), tcpClient);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task StopAsync(CancellationToken cancellationToken)
{
foreach (FakePlc plc in this.fakePlcList)
{
await plc.StopAsync().ConfigureAwait(true);
await plc.StopAsync().ConfigureAwait(false);
}
}

Expand All @@ -64,7 +64,7 @@ protected virtual void Dispose(bool disposing)
{
foreach (FakePlc plc in this.fakePlcList)
{
plc.StopAsync().ConfigureAwait(true).GetAwaiter().GetResult();
plc.StopAsync().ConfigureAwait(false).GetAwaiter().GetResult();
plc.Dispose();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private async void AskPersistDeviceAlarm(object state)
new GetAlarmRequest(),
DateTime.UtcNow.AddMilliseconds(
coreOptions.Value.DefaultReadTimeoutMillis))
.ConfigureAwait(true);
.ConfigureAwait(false);

var m = new ModelAlarm
{
Expand Down Expand Up @@ -532,7 +532,7 @@ private async void AskPersistDeviceMetric(object state)
new GetMetricRequest(),
DateTime.UtcNow.AddMilliseconds(
coreOptions.Value.DefaultReadTimeoutMillis))
.ConfigureAwait(true);
.ConfigureAwait(false);

var m = new ModelMetric
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public Task StartAsync(CancellationToken cancellationToken)
public async Task StopAsync()
{
this.cancellationTokenSource.Cancel();
await this.backgroundTask.ConfigureAwait(true);
await this.backgroundTask.ConfigureAwait(false);

foreach (ByteString id in this.PlcDictionary.Keys)
{
if (this.PlcDictionary.TryRemove(id, out PlcClient client))
{
await client.Close().ConfigureAwait(true);
await client.Close().ConfigureAwait(false);
client.Dispose();
}
}
Expand All @@ -87,7 +87,7 @@ private async void BackgroundTaskEntryPoint()
PlcClient client = null;
try
{
client = await this.plcServer.AcceptAsync().ConfigureAwait(true);
client = await this.plcServer.AcceptAsync().ConfigureAwait(false);
this.logger.LogInformation("TCP connection established from {0}", client.RemoteEndPoint);
}
catch (SocketException e)
Expand All @@ -106,15 +106,19 @@ private async void BackgroundTaskEntryPoint()
{
response = await client
.ConnectAsync(new ConnectRequest(), DateTime.UtcNow.AddSeconds(10))
.ConfigureAwait(true);
.ConfigureAwait(false);
this.logger.LogInformation(
"ConnectResponse received from newly PLC {0}: {1}",
client.RemoteEndPoint,
response);
}
catch (RpcException e)
{
this.logger.LogWarning(
e,
"Failed to send ConnectRequest to newly PLC {0}, hang up.",
client.RemoteEndPoint);
await client.Close().ConfigureAwait(true);
await client.Close().ConfigureAwait(false);
client.Dispose();
continue;
}
Expand All @@ -141,7 +145,7 @@ private async void BackgroundTaskEntryPoint()
"Failed to add the client(MAC={0}, EndPoint={1}) into dictionary.",
BitConverter.ToString(response.Id.ToByteArray()),
client.RemoteEndPoint);
await client.Close().ConfigureAwait(true);
await client.Close().ConfigureAwait(false);
client.Dispose();
}
}
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ steps:
publishDirectory: '$(Build.ArtifactStagingDirectory)'
feedsToUsePublish: 'internal'
vstsFeedPublish: '6fdda69a-feef-492b-9027-6ca329dcade4/af8d15e0-742a-4658-a87e-06eb29c6e60e'
vstsFeedPackagePublish: 'OneDotNet'
vstsFeedPackagePublish: 'one-dotnet'
versionOption: 'patch'

0 comments on commit 4a088bc

Please sign in to comment.