private void StartGameProcessMonitoring() { var dispatcher = Dispatcher.CurrentDispatcher; ThreadPool.QueueUserWorkItem(_ => { while (gameProcessMonitoring.Wait(1000) == false) { bool localIsRunGameLocked = dispatcher.Invoke(() => IsRunGameLocked); var processes = Process.GetProcessesByName(Constants.ProcessName); if (processes.Length > 0 && IsRunGameLocked == false) { dispatcher.Invoke(() => { IsRunGameLocked = true; Status = "Dark Souls 3 is running..."; GameStarted?.Invoke(this, EventArgs.Empty); }); } else if (processes.Length == 0 && IsRunGameLocked) { dispatcher.Invoke(() => { IsRunGameLocked = false; Status = "Dark Souls 3 has stopped..."; GameStopped?.Invoke(this, EventArgs.Empty); }); } } gameProcessMonitoring.Reset(); }); }
public async Task StopGameAsync() { if (CoreRunner != null) { await CoreRunner.UnloadGameAsync(); } CleanupAndGoBack(); GameStopped?.Invoke(this); }
public async Task Connect() { _hubConnection = new HubConnectionBuilder().WithUrl(_hubUri).Build(); _hubConnection.On(GameEvents.GameSessionStarted, () => GameSessionStarted?.Invoke()); _hubConnection.On <bool>(nameof(IsSessionOpen), (isOpen) => IsSessionOpen?.Invoke(isOpen)); _hubConnection.On(GameEvents.PlayerCreated, () => PlayerCreated?.Invoke()); _hubConnection.On <ICollection <string> >(nameof(IncomingPlayers), (players) => IncomingPlayers?.Invoke(players)); _hubConnection.On(GameEvents.GameStarted, () => GameStarted?.Invoke()); _hubConnection.On <int>(GameEvents.TimeElapsed, countDownSeconds => TimeElapsed?.Invoke(countDownSeconds)); _hubConnection.On(GameEvents.GameStopped, () => GameStopped?.Invoke()); _hubConnection.On <int>(GameEvents.RightAnswer, newScore => SentRightAnswer?.Invoke(newScore)); _hubConnection.On <int>(GameEvents.WrongAnswer, newScore => SentWrongAnswer?.Invoke(newScore)); _hubConnection.On(GameEvents.RoundEnded, () => RoundEnded?.Invoke()); _hubConnection.On <string>(GameEvents.Question, question => QuestionSent?.Invoke(question)); _hubConnection.On <AnswerAndPlayers>(GameEvents.AnswerAndPlayers, answerAndPlayers => GotAnswerAndPlayers?.Invoke(answerAndPlayers)); _hubConnection.On(GameEvents.NextRoundStarted, () => NextRoundStarted?.Invoke()); await _hubConnection.StartAsync(); }
private void OnGameStopped(GameStopped seerEvent) => GameStopped?.Invoke(seerEvent);
public void GameStop() { _generator.Stop(); GameStopped?.Invoke(); }