예제 #1
0
        public void Should_Set_Thread_ID()
        {
            // Given, When
            var result = new StoppedListeningEvent(1);

            // Then
            Assert.Equal(1, result.ThreadId);
        }
예제 #2
0
        public void Handle(StoppedListeningEvent message)
        {
            Debug.Assert(message.ThreadId > -1, "Invalid thread ID recieved.");
            _logger.Information("Received StoppedListeningEvent (#{0})", message.ThreadId);

            // Find the view model mapping from the thread ID.
            var mapping = _mappings.SingleOrDefault(x => x.ThreadId == message.ThreadId);

            if (mapping != null)
            {
                var removed = _mappings.Remove(mapping);
                Debug.Assert(removed, "Could not remove view model mapping.");
                this.CloseItem(mapping.ViewModel);
            }

            NotifyOfPropertyChange(() => CanPause);
            NotifyOfPropertyChange(() => CanResume);
            NotifyOfPropertyChange(() => CanOpenListener);
            NotifyOfPropertyChange(() => CanCloseListener);
            NotifyOfPropertyChange(() => HasListeners);
        }