コード例 #1
0
        public async void StartInstallWatcher()
        {
            logger.Info("StartInstallWatcher started:" + Game.GameId);
            if (watcherToken != null)
            {
                watcherToken.CancelAfter(200);
                await Task.Delay(1000);
            }
            watcherToken = new CancellationTokenSource();
            var stopWatch = Stopwatch.StartNew();

            watcherToken.CancelAfter(30000);
            while (true)
            {
                if (watcherToken.IsCancellationRequested)
                {
                    return;
                }

                var games = library.GetInstalledGames();

                if (games.ContainsKey(Game.GameId))
                {
                    logger.Info("Installer " + Game.GameId);
                    var game = games[Game.GameId];
                    stopWatch.Stop();
                    var installInfo = new GameInfo()
                    {
                        PlayAction       = game.PlayAction,
                        OtherActions     = game.OtherActions,
                        InstallDirectory = game.InstallDirectory
                    };

                    OnInstalled(this, new GameInstalledEventArgs(game, this, stopWatch.Elapsed.TotalSeconds));
                    return;
                }

                await Task.Delay(5000);
            }
        }