public async void StartInstallWatcher() { watcherToken = new CancellationTokenSource(); await Task.Run(async() => { var app = BattleNetGames.GetAppDefinition(Game.GameId); while (true) { if (watcherToken.IsCancellationRequested) { return; } var install = BattleNetLibrary.GetUninstallEntry(app); if (install == null) { await Task.Delay(2000); continue; } else { if (Game.PlayAction == null) { if (app.Type == BNetAppType.Classic) { Game.PlayAction = new GameAction() { Type = GameActionType.File, WorkingDir = @"{InstallDir}", Path = app.ClassicExecutable }; } else { Game.PlayAction = BattleNetLibrary.GetGamePlayTask(Game.GameId); } } Game.InstallDirectory = install.InstallLocation; OnInstalled(this, new GameControllerEventArgs(this, 0)); return; } } }); }
public async void StartInstallWatcher() { watcherToken = new CancellationTokenSource(); var app = BattleNetGames.GetAppDefinition(Game.GameId); while (true) { if (watcherToken.IsCancellationRequested) { return; } var install = BattleNetLibrary.GetUninstallEntry(app); if (install == null) { await Task.Delay(2000); continue; } else { var installInfo = new GameInfo() { InstallDirectory = install.InstallLocation }; if (app.Type == BNetAppType.Classic) { installInfo.PlayAction = new GameAction() { Type = GameActionType.File, WorkingDir = ExpandableVariables.InstallationDirectory, Path = app.ClassicExecutable }; } else { installInfo.PlayAction = BattleNetLibrary.GetGamePlayTask(Game.GameId); } OnInstalled(this, new GameInstalledEventArgs(installInfo, this, 0)); return; } } }