Skip to content

Commit dd1daee

Browse files
authored
Replace async void with async task (BornToBeRoot#593)
* Replace async void with async task * BornToBeRoot#383 Co-authored-by: BornToBeRoot <BornToBeRoot@users.noreply.github.com>
1 parent 05926af commit dd1daee

44 files changed

Lines changed: 130 additions & 109 deletions

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/DragablzTabHostWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using MahApps.Metro.Controls.Dialogs;
1111
using NETworkManager.Localization.Translators;
1212
using NETworkManager.Models;
13+
using System.Threading.Tasks;
1314

1415
namespace NETworkManager.Controls
1516
{
@@ -177,7 +178,7 @@ private async void RemoteDesktop_SendCtrlAltDelAction(object view)
177178
{
178179
ConfigurationManager.Current.FixAirspace = true;
179180

180-
await this.ShowMessageAsync(NETworkManager.Localization.Resources.Strings.Error, string.Format("{0}\n\nMessage:\n{1}", NETworkManager.Localization.Resources.Strings.CouldNotSendKeystroke, ex.Message, MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog));
181+
await this.ShowMessageAsync(Localization.Resources.Strings.Error, string.Format("{0}\n\nMessage:\n{1}", NETworkManager.Localization.Resources.Strings.CouldNotSendKeystroke, ex.Message, MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog));
181182

182183
ConfigurationManager.Current.FixAirspace = false;
183184
}

Source/NETworkManager/Controls/PowerShellControl.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ private void ReconnectAction()
117117
#endregion
118118

119119
#region Methods
120-
private async void Connect()
120+
private async Task Connect()
121121
{
122122
IsConnecting = true;
123123

124124
var info = new ProcessStartInfo
125125
{
126126
FileName = _sessionInfo.ApplicationFilePath,
127-
Arguments = Models.PowerShell.PowerShell.BuildCommandLine(_sessionInfo)
127+
Arguments = PowerShell.BuildCommandLine(_sessionInfo)
128128
};
129129

130130
try

Source/NETworkManager/Controls/PuTTYControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void ReconnectAction()
119119
#endregion
120120

121121
#region Methods
122-
private async void Connect()
122+
private async Task Connect()
123123
{
124124
IsConnecting = true;
125125

Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ private void RdpGrid_SizeChanged(object sender, SizeChangedEventArgs e)
446446
InitiateReconnection();
447447
}
448448

449-
private async void InitiateReconnection()
449+
private async Task InitiateReconnection()
450450
{
451451
IsReconnecting = true;
452452

Source/NETworkManager/Controls/TightVNCControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private void ReconnectAction()
118118
#endregion
119119

120120
#region Methods
121-
private async void Connect()
121+
private async Task Connect()
122122
{
123123
IsConnecting = true;
124124

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
using NETworkManager.Models;
2929
using NETworkManager.Models.EventSystem;
3030
using System.Windows.Threading;
31+
using System.Threading.Tasks;
3132

3233
namespace NETworkManager
3334
{
@@ -881,7 +882,7 @@ private void EventSystem_RedirectToSettingsEvent(object sender, EventArgs e)
881882
OpenSettings();
882883
}
883884

884-
private async void CloseSettings()
885+
private async Task CloseSettings()
885886
{
886887
ShowSettingsView = false;
887888

@@ -943,7 +944,7 @@ private void SettingsManager_PropertyChanged(object sender, PropertyChangedEvent
943944
#endregion
944945

945946
#region Profiles
946-
private async void LoadProfile(ProfileFileInfo info)
947+
private async Task LoadProfile(ProfileFileInfo info)
947948
{
948949
if (info.IsEncrypted && !info.IsPasswordValid)
949950
{
@@ -979,7 +980,7 @@ private async void LoadProfile(ProfileFileInfo info)
979980
}
980981
}
981982

982-
private async void SwitchProfile(ProfileFileInfo info)
983+
private async Task SwitchProfile(ProfileFileInfo info)
983984
{
984985
try
985986
{

Source/NETworkManager/ProfileDialogManager.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
using NETworkManager.Profiles;
33
using NETworkManager.ViewModels;
44
using NETworkManager.Views;
5+
using System.Threading.Tasks;
56

67
namespace NETworkManager
78
{
89
public static class ProfileDialogManager
910
{
1011

1112
#region Add profile, Edit profile, CopyAs profile, Delete profile, Edit group
12-
public static async void ShowAddProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator)
13+
public static async Task ShowAddProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator)
1314
{
1415
var customDialog = new CustomDialog
1516
{
@@ -38,7 +39,7 @@ public static async void ShowAddProfileDialog(IProfileManager viewModel, IDialog
3839
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
3940
}
4041

41-
public static async void ShowEditProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo selectedProfile)
42+
public static async Task ShowEditProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo selectedProfile)
4243
{
4344
var customDialog = new CustomDialog
4445
{
@@ -68,7 +69,7 @@ public static async void ShowEditProfileDialog(IProfileManager viewModel, IDialo
6869
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
6970
}
7071

71-
public static async void ShowCopyAsProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo selectedProfile)
72+
public static async Task ShowCopyAsProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo selectedProfile)
7273
{
7374
var customDialog = new CustomDialog
7475
{
@@ -96,7 +97,7 @@ public static async void ShowCopyAsProfileDialog(IProfileManager viewModel, IDia
9697
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
9798
}
9899

99-
public static async void ShowDeleteProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo selectedProfile)
100+
public static async Task ShowDeleteProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo selectedProfile)
100101
{
101102
var customDialog = new CustomDialog
102103
{
@@ -124,7 +125,7 @@ public static async void ShowDeleteProfileDialog(IProfileManager viewModel, IDia
124125
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
125126
}
126127

127-
public static async void ShowEditGroupDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, string group)
128+
public static async Task ShowEditGroupDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, string group)
128129
{
129130
var customDialog = new CustomDialog
130131
{

Source/NETworkManager/StatusWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void OpenMainWindowAction()
151151
#endregion
152152

153153
#region Methods
154-
private async void Refresh(bool startTimer = false)
154+
private async Task Refresh(bool startTimer = false)
155155
{
156156
IsRefreshing = true;
157157

Source/NETworkManager/ViewModels/ARPTableViewModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public ARPTableViewModel(IDialogCoordinator instance)
214214
Run();
215215
}
216216

217-
private async void Run()
217+
private async Task Run()
218218
{
219219
await Refresh();
220220

@@ -236,7 +236,7 @@ private bool Refresh_CanExecute(object paramter)
236236
return Application.Current.MainWindow != null && !((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen;
237237
}
238238

239-
private async void RefreshAction()
239+
private async Task RefreshAction()
240240
{
241241
IsStatusMessageDisplayed = false;
242242

@@ -250,7 +250,7 @@ private bool DeleteTable_CanExecute(object paramter)
250250
return Application.Current.MainWindow != null && !((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen;
251251
}
252252

253-
private async void DeleteTableAction()
253+
private async Task DeleteTableAction()
254254
{
255255
IsStatusMessageDisplayed = false;
256256

@@ -275,7 +275,7 @@ private async void DeleteTableAction()
275275

276276
private bool DeleteEntry_CanExecute(object paramter) => Application.Current.MainWindow != null && !((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen;
277277

278-
private async void DeleteEntryAction()
278+
private async Task DeleteEntryAction()
279279
{
280280
IsStatusMessageDisplayed = false;
281281

@@ -300,7 +300,7 @@ private async void DeleteEntryAction()
300300

301301
private bool AddEntry_CanExecute(object paramter) => Application.Current.MainWindow != null && !((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen;
302302

303-
private async void AddEntryAction()
303+
private async Task AddEntryAction()
304304
{
305305
IsStatusMessageDisplayed = false;
306306

@@ -364,7 +364,7 @@ private void CopySelectedMulticastAction()
364364

365365
public ICommand ExportCommand => new RelayCommand(p => ExportAction());
366366

367-
private async void ExportAction()
367+
private async Task ExportAction()
368368
{
369369
var customDialog = new CustomDialog
370370
{

Source/NETworkManager/ViewModels/ConnectionsViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public ConnectionsViewModel(IDialogCoordinator instance)
214214
Run();
215215
}
216216

217-
private async void Run()
217+
private async Task Run()
218218
{
219219
await Refresh();
220220

@@ -236,7 +236,7 @@ private bool Refresh_CanExecute(object paramter)
236236
return Application.Current.MainWindow != null && !((MetroWindow)Application.Current.MainWindow).IsAnyDialogOpen;
237237
}
238238

239-
private async void RefreshAction()
239+
private async Task RefreshAction()
240240
{
241241
IsStatusMessageDisplayed = false;
242242

@@ -287,7 +287,7 @@ private void CopySelectedStateAction()
287287

288288
public ICommand ExportCommand => new RelayCommand(p => ExportAction());
289289

290-
private async void ExportAction()
290+
private async Task ExportAction()
291291
{
292292
var customDialog = new CustomDialog
293293
{

0 commit comments

Comments
 (0)