diff --git a/FASTER/ViewModel/SteamUpdaterViewModel.cs b/FASTER/ViewModel/SteamUpdaterViewModel.cs index d6a231b..6bd7532 100644 --- a/FASTER/ViewModel/SteamUpdaterViewModel.cs +++ b/FASTER/ViewModel/SteamUpdaterViewModel.cs @@ -26,7 +26,7 @@ namespace FASTER.ViewModel { - public sealed class SteamUpdaterViewModel : INotifyPropertyChanged + public sealed class SteamUpdaterViewModel : INotifyPropertyChanged, IDisposable { public SteamUpdaterViewModel() { @@ -510,6 +510,8 @@ public async Task RunModsUpdater(ObservableCollection mods) internal async Task SteamLogin() { + if (tokenSource.IsCancellationRequested) + tokenSource = new CancellationTokenSource(); IsLoggingIn = true; var path = Path.Combine(Path.GetDirectoryName(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath) ?? string.Empty, "sentries"); @@ -530,7 +532,7 @@ internal async Task SteamLogin() Parameters.Output += $"\nConnecting to Steam as {(_steamCredentials.IsAnonymous ? "anonymous" : _steamCredentials.Username)}"; SteamClient.MaximumLogonAttempts = 5; try - { await SteamClient.ConnectAsync(); } + { await SteamClient.ConnectAsync(tokenSource.Token); } catch (SteamClientAlreadyRunningException) { Parameters.Output += $"\nClient already logged in."; @@ -746,6 +748,11 @@ private void RaisePropertyChanged(string property) if (PropertyChanged == null) return; PropertyChanged(this, new PropertyChangedEventArgs(property)); } + + public void Dispose() + { + tokenSource.Dispose(); + } } public static class UpdateState