public static void Main(string[] args)
        {
            Console.WriteLine("Time to write something to console");

            var watcher  = new ConsoleQuitMessageSource();
            var listener = new ConsoleQuitMessageListener();

            listener.Subscribe(watcher);

            watcher.WatchConsole();
            watcher.Stop();
        }
Exemple #2
0
        public ConsoleQuitMessageSubscribeToken(ConsoleQuitMessageSource observable, IObserver <EventArgs> observer)
        {
            if (observer == null)
            {
                throw new ArgumentNullException(nameof(observer), "No observer");
            }

            if (observable == null)
            {
                throw new ArgumentNullException(nameof(observable), "No observable");
            }

            _observable = observable;
            _observer   = observer;
        }