public async void StartUninstallWatcher() { watcherToken = new CancellationTokenSource(); await Task.Run(async() => { var app = BattleNetLibrary.GetAppDefinition(Game.ProviderId); while (true) { if (watcherToken.IsCancellationRequested) { return; } var entry = BattleNetLibrary.GetUninstallEntry(app); if (entry == null) { OnUninstalled(this, new GameControllerEventArgs(this, 0)); return; } await Task.Delay(2000); } }); }
public override void Uninstall() { ReleaseResources(); var product = BattleNetLibrary.GetAppDefinition(Game.ProviderId); var entry = BattleNetLibrary.GetUninstallEntry(product); if (entry != null) { var args = string.Format("/C \"{0}\"", entry.UninstallString); ProcessStarter.StartProcess("cmd", args); StartUninstallWatcher(); } else { OnUninstalled(this, new GameControllerEventArgs(this, 0)); } }
public async void StartInstallWatcher() { watcherToken = new CancellationTokenSource(); await Task.Run(async() => { var app = BattleNetLibrary.GetAppDefinition(Game.ProviderId); while (true) { if (watcherToken.IsCancellationRequested) { return; } var install = BattleNetLibrary.GetUninstallEntry(app); if (install == null) { await Task.Delay(2000); continue; } else { if (Game.PlayTask == null) { if (app.Type == BattleNetLibrary.BNetAppType.Classic) { Game.PlayTask = new GameTask() { Type = GameTaskType.File, WorkingDir = @"{InstallDir}", Path = @"{InstallDir}\" + app.ClassicExecutable }; } else { Game.PlayTask = battleNet.GetGamePlayTask(Game.ProviderId); } } Game.InstallDirectory = install.InstallLocation; OnInstalled(this, new GameControllerEventArgs(this, 0)); return; } } }); }
public void StartInstallMonitoring() { logger.Info("Starting install monitoring of BattleNet app " + app.ProductId); Dispose(); cancelToken = new CancellationTokenSource(); Task.Factory.StartNew(() => { while (!cancelToken.Token.IsCancellationRequested) { var entry = BattleNetLibrary.GetUninstallEntry(app); if (entry != null) { logger.Info($"BattleNet app {app.ProductId} has been installed."); GameTask playTask; if (app.Type == BattleNetLibrary.BNetAppType.Classic) { playTask = new GameTask() { Type = GameTaskType.File, WorkingDir = @"{InstallDir}", Path = @"{InstallDir}\" + app.ClassicExecutable }; } else { playTask = library.GetGamePlayTask(app.ProductId); } GameInstalled?.Invoke(this, new GameInstalledEventArgs(new Game() { PlayTask = playTask, InstallDirectory = entry.InstallLocation })); return; } Thread.Sleep(5000); } }, cancelToken.Token); }
public void StartUninstallMonitoring() { logger.Info("Starting uninstall monitoring of BattleNet app " + app.ProductId); Dispose(); cancelToken = new CancellationTokenSource(); Task.Factory.StartNew(() => { while (!cancelToken.Token.IsCancellationRequested) { var entry = BattleNetLibrary.GetUninstallEntry(app); if (entry == null) { logger.Info($"BattleNet app {app.ProductId} has been uninstalled."); GameUninstalled?.Invoke(this, null); return; } Thread.Sleep(5000); } }, cancelToken.Token); }