Skip to content

Commit 97e2665

Browse files
Replace fire-and-forget ConfigureAwait(false) with explicit discards (#3441)
* refactor: use discard for fire-and-forget tasks Agent-Logs-Url: https://github.com/BornToBeRoot/NETworkManager/sessions/de1121de-997a-4477-a250-f6c05615ddd5 Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * style: simplify discard callback lambda Agent-Logs-Url: https://github.com/BornToBeRoot/NETworkManager/sessions/de1121de-997a-4477-a250-f6c05615ddd5 Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Fix: Bug... --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
1 parent 8c484be commit 97e2665

56 files changed

Lines changed: 327 additions & 404 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/NETworkManager/Controls/PowerShellControl.xaml.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
103103
WindowHost.Height = (int)((ActualHeight - 20) * dpi.DpiScaleY);
104104
WindowHost.Width = (int)((ActualWidth - 20) * dpi.DpiScaleX);
105105

106-
Connect().ConfigureAwait(false);
106+
_ = Connect();
107107

108108
_initialized = true;
109109
}
@@ -248,7 +248,7 @@ private void Reconnect()
248248
if (IsConnected)
249249
Disconnect();
250250

251-
Connect().ConfigureAwait(false);
251+
_ = Connect();
252252
}
253253

254254
public void CloseTab()

‎Source/NETworkManager/Controls/PuTTYControl.xaml.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
104104
WindowHost.Height = (int)((ActualHeight - 20) * dpi.DpiScaleY);
105105
WindowHost.Width = (int)((ActualWidth - 20) * dpi.DpiScaleX);
106106

107-
Connect().ConfigureAwait(false);
107+
_ = Connect();
108108

109109
_initialized = true;
110110
}
@@ -262,7 +262,7 @@ private void Reconnect()
262262
if (IsConnected)
263263
Disconnect();
264264

265-
Connect().ConfigureAwait(false);
265+
_ = Connect();
266266
}
267267

268268
public void RestartSession()

‎Source/NETworkManager/Controls/TigerVNCControl.xaml.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
8989
WindowHost.Height = (int)(ActualHeight * dpi.DpiScaleY);
9090
WindowHost.Width = (int)(ActualWidth * dpi.DpiScaleX);
9191

92-
Connect().ConfigureAwait(false);
92+
_ = Connect();
9393

9494
_initialized = true;
9595
}
@@ -233,7 +233,7 @@ private void Reconnect()
233233
if (IsConnected)
234234
Disconnect();
235235

236-
Connect().ConfigureAwait(false);
236+
_ = Connect();
237237
}
238238

239239
public void CloseTab()

‎Source/NETworkManager/ProfileDialogManager.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MahApps.Metro.SimpleChildWindow;
1+
using MahApps.Metro.SimpleChildWindow;
22
using NETworkManager.Controls;
33
using NETworkManager.Localization.Resources;
44
using NETworkManager.Models;
@@ -581,7 +581,7 @@ void CloseChild()
581581
switch (instance.SelectedMethod.Method)
582582
{
583583
case ProfileImportSource.ActiveDirectory:
584-
ShowSearchAdComputersDialog(parentWindow, viewModel, targetGroup, previousState: null).ConfigureAwait(false);
584+
_ = ShowSearchAdComputersDialog(parentWindow, viewModel, targetGroup, previousState: null);
585585
break;
586586
}
587587
}, _ => CloseChild());
@@ -614,10 +614,9 @@ void CloseChild()
614614
{
615615
CloseChild();
616616

617-
ShowImportProfilesResultDialog(parentWindow, viewModel, targetGroup, candidates,
617+
_ = ShowImportProfilesResultDialog(parentWindow, viewModel, targetGroup, candidates,
618618
ProfileImportSource.ActiveDirectory, Strings.ImportProfiles_Source_ActiveDirectory,
619-
backToSourceCallback: () => ShowSearchAdComputersDialog(parentWindow, viewModel, targetGroup, searchViewModel).ConfigureAwait(false)
620-
).ConfigureAwait(false);
619+
backToSourceCallback: () => _ = ShowSearchAdComputersDialog(parentWindow, viewModel, targetGroup, searchViewModel));
621620
}, CloseChild, previousState);
622621

623622
childWindow.Title = Strings.ImportComputersFromActiveDirectory;

‎Source/NETworkManager/ViewModels/BitCalculatorViewModel.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using log4net;
1+
using log4net;
22
using MahApps.Metro.Controls;
33
using MahApps.Metro.SimpleChildWindow;
44
using NETworkManager.Localization.Resources;
@@ -197,7 +197,7 @@ private void CalculateAction()
197197
/// <summary>
198198
/// Gets the command to export the result.
199199
/// </summary>
200-
public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false));
200+
public ICommand ExportCommand => new RelayCommand(parameter => { _ = ExportAction(); });
201201

202202
/// <summary>
203203
/// Action to export the result.

‎Source/NETworkManager/ViewModels/ConnectionsViewModel.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using log4net;
1+
using log4net;
22
using MahApps.Metro.Controls;
33
using MahApps.Metro.SimpleChildWindow;
44
using NETworkManager.Localization;
@@ -65,7 +65,7 @@ public ConnectionsViewModel()
6565
};
6666

6767
// Get connections
68-
Refresh(true).ConfigureAwait(false);
68+
_ = Refresh(true);
6969

7070
// Auto refresh
7171
_autoRefreshTimer.Tick += AutoRefreshTimer_Tick;
@@ -303,7 +303,7 @@ public string StatusMessage
303303
/// <summary>
304304
/// Gets the command to refresh the connections.
305305
/// </summary>
306-
public ICommand RefreshCommand => new RelayCommand(_ => RefreshAction().ConfigureAwait(false), Refresh_CanExecute);
306+
public ICommand RefreshCommand => new RelayCommand(parameter => { _ = RefreshAction(); }, Refresh_CanExecute);
307307

308308
/// <summary>
309309
/// Checks if the refresh command can be executed.
@@ -332,7 +332,7 @@ private async Task RefreshAction()
332332
/// <summary>
333333
/// Gets the command to export the connections.
334334
/// </summary>
335-
public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false));
335+
public ICommand ExportCommand => new RelayCommand(parameter => { _ = ExportAction(); });
336336

337337
/// <summary>
338338
/// Action to export the connections.

‎Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Dragablz;
1+
using Dragablz;
22
using NETworkManager.Controls;
33
using NETworkManager.Localization.Resources;
44
using NETworkManager.Models;
@@ -378,9 +378,8 @@ private void LookupProfileAction()
378378
/// </summary>
379379
private void AddProfileAction()
380380
{
381-
ProfileDialogManager
382-
.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.DNSLookup)
383-
.ConfigureAwait(false);
381+
_ = ProfileDialogManager
382+
.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.DNSLookup);
384383
}
385384

386385
/// <summary>
@@ -401,8 +400,7 @@ private bool ModifyProfile_CanExecute(object obj)
401400
/// </summary>
402401
private void EditProfileAction()
403402
{
404-
ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile)
405-
.ConfigureAwait(false);
403+
_ = ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile);
406404
}
407405

408406
/// <summary>
@@ -415,8 +413,7 @@ private void EditProfileAction()
415413
/// </summary>
416414
private void CopyAsProfileAction()
417415
{
418-
ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow, this, SelectedProfile)
419-
.ConfigureAwait(false);
416+
_ = ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow, this, SelectedProfile);
420417
}
421418

422419
/// <summary>
@@ -429,9 +426,8 @@ private void CopyAsProfileAction()
429426
/// </summary>
430427
private void DeleteProfileAction()
431428
{
432-
ProfileDialogManager
433-
.ShowDeleteProfileDialog(Application.Current.MainWindow, this, new List<ProfileInfo> { SelectedProfile })
434-
.ConfigureAwait(false);
429+
_ = ProfileDialogManager
430+
.ShowDeleteProfileDialog(Application.Current.MainWindow, this, new List<ProfileInfo> { SelectedProfile });
435431
}
436432

437433
/// <summary>
@@ -444,9 +440,8 @@ private void DeleteProfileAction()
444440
/// </summary>
445441
private void EditGroupAction(object group)
446442
{
447-
ProfileDialogManager
448-
.ShowEditGroupDialog(Application.Current.MainWindow, this, ProfileManager.GetGroupByName($"{group}"))
449-
.ConfigureAwait(false);
443+
_ = ProfileDialogManager
444+
.ShowEditGroupDialog(Application.Current.MainWindow, this, ProfileManager.GetGroupByName($"{group}"));
450445
}
451446

452447
/// <summary>

‎Source/NETworkManager/ViewModels/DNSLookupSettingsViewModel.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DnsClient;
1+
using DnsClient;
22
using MahApps.Metro.SimpleChildWindow;
33
using NETworkManager.Localization.Resources;
44
using NETworkManager.Models.Network;
@@ -299,7 +299,7 @@ private void LoadSettings()
299299
/// </summary>
300300
private void AddDNSServerAction()
301301
{
302-
AddDNSServer().ConfigureAwait(false);
302+
_ = AddDNSServer();
303303
}
304304

305305
/// <summary>
@@ -312,7 +312,7 @@ private void AddDNSServerAction()
312312
/// </summary>
313313
private void EditDNSServerAction()
314314
{
315-
EditDNSServer().ConfigureAwait(false);
315+
_ = EditDNSServer();
316316
}
317317

318318
/// <summary>
@@ -325,7 +325,7 @@ private void EditDNSServerAction()
325325
/// </summary>
326326
private void DeleteDNSServerAction()
327327
{
328-
DeleteDNSServer().ConfigureAwait(false);
328+
_ = DeleteDNSServer();
329329
}
330330

331331
#endregion

‎Source/NETworkManager/ViewModels/DNSLookupViewModel.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DnsClient;
1+
using DnsClient;
22
using log4net;
33
using MahApps.Metro.Controls;
44
using MahApps.Metro.SimpleChildWindow;
@@ -288,7 +288,7 @@ public void OnLoaded()
288288
return;
289289

290290
if (!string.IsNullOrEmpty(Host))
291-
QueryAsync().ConfigureAwait(false);
291+
_ = QueryAsync();
292292

293293
_firstLoad = false;
294294
}
@@ -343,7 +343,7 @@ private bool Query_CanExecute(object parameter)
343343
private void QueryAction()
344344
{
345345
if (!IsRunning)
346-
QueryAsync().ConfigureAwait(false);
346+
_ = QueryAsync();
347347
}
348348

349349
/// <summary>
@@ -356,7 +356,7 @@ private void QueryAction()
356356
/// </summary>
357357
private void ExportAction()
358358
{
359-
Export().ConfigureAwait(false);
359+
_ = Export();
360360
}
361361

362362
#endregion

‎Source/NETworkManager/ViewModels/DiscoveryProtocolViewModel.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using log4net;
1+
using log4net;
22
using MahApps.Metro.SimpleChildWindow;
33
using NETworkManager.Localization.Resources;
44
using NETworkManager.Models.Export;
@@ -275,7 +275,7 @@ private void LoadSettings()
275275
/// <summary>
276276
/// Gets the command to restart the application as administrator.
277277
/// </summary>
278-
public ICommand RestartAsAdminCommand => new RelayCommand(_ => RestartAsAdminAction().ConfigureAwait(false));
278+
public ICommand RestartAsAdminCommand => new RelayCommand(parameter => { _ = RestartAsAdminAction(); });
279279

280280
/// <summary>
281281
/// Action to restart the application as administrator.
@@ -295,7 +295,7 @@ private async Task RestartAsAdminAction()
295295
/// <summary>
296296
/// Gets the command to start the capture.
297297
/// </summary>
298-
public ICommand CaptureCommand => new RelayCommand(_ => CaptureAction().ConfigureAwait(false), Capture_CanExecute);
298+
public ICommand CaptureCommand => new RelayCommand(parameter => { _ = CaptureAction(); }, Capture_CanExecute);
299299

300300
private bool Capture_CanExecute(object _) => ConfigurationManager.Current.IsAdmin && !IsCapturing;
301301

@@ -337,7 +337,7 @@ private async Task CaptureAction()
337337
/// <summary>
338338
/// Gets the command to export the result.
339339
/// </summary>
340-
public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false));
340+
public ICommand ExportCommand => new RelayCommand(parameter => { _ = ExportAction(); });
341341

342342
/// <summary>
343343
/// Action to export the result.

0 commit comments

Comments
 (0)