Skip to content

Commit 462ece5

Browse files
chore: configureawait
1 parent 192c989 commit 462ece5

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/SiteMonitor/ViewModels/MainWindowViewModel.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public string? SshPassword {
180180
/// </summary>
181181
private async Task OnRestart() {
182182
using SshClient client = new(_serverAddress!, _sshUsername!, _sshPassword!);
183-
await client.ConnectAsync(CancellationToken.None);
183+
await client.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
184184
string command = "shutdown -r now";
185185
using SshCommand? ssh = client.RunCommand($"echo {_sshPassword} | sudo -S {command}");
186186
}
@@ -191,7 +191,7 @@ private async Task OnRestart() {
191191
private async Task OnRestartImages() {
192192
await Task.Run(async () => {
193193
using SshClient client = new(_serverAddress!, _sshUsername!, _sshPassword!);
194-
await client.ConnectAsync(CancellationToken.None);
194+
await client.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
195195
string[] command = [
196196
"docker compose -p nullinside-ui restart",
197197
"docker compose -p nullinside-api restart",
@@ -202,7 +202,7 @@ await Task.Run(async () => {
202202
foreach (string line in command) {
203203
using SshCommand? ssh = client.RunCommand($"echo {_sshPassword} | sudo -S {line}");
204204
}
205-
});
205+
}).ConfigureAwait(false);
206206
}
207207

208208
/// <summary>
@@ -217,10 +217,10 @@ private void OnShowCommands() {
217217
/// </summary>
218218
private async Task PingSite() {
219219
while (true) {
220-
WebsiteUp = await SendHeadRequest("https://nullinside.com");
221-
ApiUp = await SendHeadRequest("https://nullinside.com/api/v1/featureToggle");
222-
NullUp = await SendHeadRequest("https://nullinside.com/null/v1/database/migration");
223-
(HttpStatusCode, string?) chat = await SendGetRequest("https://nullinside.com/twitch-bot/v1/bot/chat/timestamp");
220+
WebsiteUp = await SendHeadRequest("https://nullinside.com").ConfigureAwait(false);
221+
ApiUp = await SendHeadRequest("https://nullinside.com/api/v1/featureToggle").ConfigureAwait(false);
222+
NullUp = await SendHeadRequest("https://nullinside.com/null/v1/database/migration").ConfigureAwait(false);
223+
(HttpStatusCode, string?) chat = await SendGetRequest("https://nullinside.com/twitch-bot/v1/bot/chat/timestamp").ConfigureAwait(false);
224224
bool chatNotUpdating = false;
225225
if (HttpStatusCode.OK == chat.Item1 && null != chat.Item2) {
226226
ChatTimestamp = chat.Item2;
@@ -242,7 +242,7 @@ private async Task PingSite() {
242242
WindowState = WindowState.Normal;
243243
}
244244

245-
await Task.Delay(TimeSpan.FromSeconds(10));
245+
await Task.Delay(TimeSpan.FromSeconds(10)).ConfigureAwait(false);
246246
}
247247
}
248248

@@ -258,7 +258,7 @@ private async Task<bool> SendHeadRequest(string address) {
258258
using var httpClient = new HttpClient(handler);
259259
using var request = new HttpRequestMessage(HttpMethod.Get, address);
260260
request.Headers.TryAddWithoutValidation("user-agent", Nullinside.Api.Common.Constants.FAKE_USER_AGENT);
261-
HttpResponseMessage response = await httpClient.SendAsync(request);
261+
HttpResponseMessage response = await httpClient.SendAsync(request).ConfigureAwait(false);
262262
return response.IsSuccessStatusCode;
263263
}
264264
catch {
@@ -278,8 +278,8 @@ private async Task<bool> SendHeadRequest(string address) {
278278
using var httpClient = new HttpClient(handler);
279279
using var request = new HttpRequestMessage(HttpMethod.Get, address);
280280
request.Headers.TryAddWithoutValidation("user-agent", Nullinside.Api.Common.Constants.FAKE_USER_AGENT);
281-
HttpResponseMessage response = await httpClient.SendAsync(request);
282-
return (response.StatusCode, await response.Content.ReadAsStringAsync());
281+
HttpResponseMessage response = await httpClient.SendAsync(request).ConfigureAwait(false);
282+
return (response.StatusCode, await response.Content.ReadAsStringAsync().ConfigureAwait(false));
283283
}
284284
catch {
285285
return (HttpStatusCode.InternalServerError, null);
@@ -299,7 +299,7 @@ private async Task PingServer() {
299299
}
300300
catch { }
301301
finally {
302-
await Task.Delay(TimeSpan.FromSeconds(10));
302+
await Task.Delay(TimeSpan.FromSeconds(10)).ConfigureAwait(false);
303303
}
304304
}
305305
}

src/SiteMonitor/ViewModels/NewVersionWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public NewVersionWindowViewModel() {
4747
// asynchronously determine the current version number.
4848
Task.Factory.StartNew(async () => {
4949
GithubLatestReleaseJson? version =
50-
await GitHubUpdateManager.GetLatestVersion("nullinside-development-group", "nullinside-site-monitor");
50+
await GitHubUpdateManager.GetLatestVersion("nullinside-development-group", "nullinside-site-monitor").ConfigureAwait(false);
5151

5252
if (null == version) {
5353
return;

src/SiteMonitor/Views/MainWindow.axaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected override void OnInitialized() {
6464
// check for a new version of the application.
6565
Task.Factory.StartNew(async () => {
6666
GithubLatestReleaseJson? serverVersion =
67-
await GitHubUpdateManager.GetLatestVersion("nullinside-development-group", "nullinside-site-monitor");
67+
await GitHubUpdateManager.GetLatestVersion("nullinside-development-group", "nullinside-site-monitor").ConfigureAwait(false);
6868
if (null == serverVersion || string.IsNullOrWhiteSpace(serverVersion.name)) {
6969
return;
7070
}
@@ -90,7 +90,7 @@ protected override void OnInitialized() {
9090
DataContext = vm
9191
};
9292

93-
await versionWindow.ShowDialog(this);
93+
await versionWindow.ShowDialog(this).ConfigureAwait(false);
9494
}
9595
catch {
9696
// do nothing, don't crash

src/nullinside-api

0 commit comments

Comments
 (0)