diff --git a/UWPHook/GamesWindow.xaml.cs b/UWPHook/GamesWindow.xaml.cs
index f7461e3..56b7e32 100644
--- a/UWPHook/GamesWindow.xaml.cs
+++ b/UWPHook/GamesWindow.xaml.cs
@@ -155,7 +155,8 @@ namespace UWPHook
try
{
- await ExportGames(restartSteam);
+ await ExportGames();
+ await RestartSteam(restartSteam);
msg = "Your apps were successfuly exported!";
if(!restartSteam)
@@ -339,7 +340,7 @@ namespace UWPHook
///
///
///
- private async Task ExportGames(bool restartSteam)
+ private async Task ExportGames()
{
string[] tags = Settings.Default.Tags.Split(',');
string steam_folder = SteamManager.GetSteamFolder();
@@ -470,49 +471,51 @@ namespace UWPHook
}
}
- if(restartSteam)
- {
- Func getSteam = () => Process.GetProcessesByName("steam").SingleOrDefault();
+ return true;
+ }
- Process steam = getSteam();
- if (steam != null)
- {
- string steamExe = steam.MainModule.FileName;
+ private async Task RestartSteam(bool restartSteam)
+ {
+ Func getSteam = () => Process.GetProcessesByName("steam").SingleOrDefault();
- //we always ask politely
- Debug.WriteLine("Requesting Steam shutdown");
- Process.Start(steamExe, "-exitsteam");
+ Process steam = getSteam();
+ if (steam != null)
+ {
+ string steamExe = steam.MainModule.FileName;
- bool restarted = false;
- Stopwatch watch = new Stopwatch();
- watch.Start();
+ //we always ask politely
+ Debug.WriteLine("Requesting Steam shutdown");
+ Process.Start(steamExe, "-exitsteam");
- //give it N seconds to sort itself out
- int waitSeconds = 8;
- while (watch.Elapsed.TotalSeconds < waitSeconds)
- {
- Thread.Sleep(TimeSpan.FromSeconds(0.5f));
- if (getSteam() == null)
- {
- Debug.WriteLine("Restarting Steam");
- Process.Start(steamExe);
- restarted = true;
- break;
- }
- }
+ bool restarted = false;
+ Stopwatch watch = new Stopwatch();
+ watch.Start();
- if (!restarted)
+ //give it N seconds to sort itself out
+ int waitSeconds = 8;
+ while (!restarted || watch.Elapsed.TotalSeconds < waitSeconds)
+ {
+ await Task.Delay(TimeSpan.FromSeconds(0.5f));
+ if (getSteam() == null)
{
- Debug.WriteLine("Steam instance not restarted");
- MessageBox.Show("Failed to restart Steam, please launch it manually", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
- return false;
+ Debug.WriteLine("Restarting Steam");
+ Process.Start(steamExe);
+ restarted = true;
+ break;
}
}
- else
+
+ if (!restarted)
{
- Debug.WriteLine("Steam instance not found to be restarted");
+ Debug.WriteLine("Steam instance not restarted");
+ MessageBox.Show("Failed to restart Steam, please launch it manually", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return false;
}
}
+ else
+ {
+ Debug.WriteLine("Steam instance not found to be restarted");
+ }
return true;
}