Example #1
0
        public void StartAndStopAreNotReentrant()
        {
            using var mkw = new ModifierKeysWatcher(new NativeMethodsMock());

            bool IsRunning() => mkw.GetPrivateField <bool>("_running");

            Assert.False(IsRunning());

            mkw.Start();
            Assert.True(IsRunning());

            mkw.Start();
            Assert.True(IsRunning());

            mkw.Stop();
            Assert.False(IsRunning());

            mkw.Stop();
            Assert.False(IsRunning());
        }
        public void Start()
        {
            if (_running)
            {
                return;
            }

            _running = true;

            _graphicsConfig.Start();
            _bindingsWatcher.Start();
            _statusWatcher.Start();
            _modifierKeysWatcher.Start();
            _journalWatcher.Start();

            if (DetectForegroundProcess)
            {
                _gameProcessWatcher.Start();
            }
        }