Ejemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////////

        #region [ Constructor ]

        /// <summary>
        /// Initializes static members of the Application class. (Internal)
        /// </summary>
        ///
        static Application()
        {
            Screen          = null;
            StatusBarWindow = null;

            DefaultStatusBarText = "Ready.";
            ErrorMessage         = null;

            ExtraLogArea        = 0;
            InitialWindowWidth  = 0;
            InitialWindowHeight = 0;

            Overwrite = false;

            Theme = new ColorTheme();

            ExceptionHandler = null;

            MessageQueue = new ConsoleKeyReader();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            var consoleKeyReader = new ConsoleKeyReader();

            IObservable<IEvent<EventArgs>> keyEvents = Observable.FromEvent<EventArgs>(consoleKeyReader, "KeyPressed");

            int keyPressCount = 0;

            Action<IEvent<EventArgs>> incrementKeyCount = e => Interlocked.Increment(ref keyPressCount);
            Action<IEvent<EventArgs>> displayKeyCount = e =>
            {
                int currentKeyCount = Interlocked.Exchange(ref keyPressCount, 0);
                Console.WriteLine();
                Console.WriteLine("Key pressed {0} times in the last 2.5 seconds.", currentKeyCount);
            };

            Console.WriteLine("Start typing and hit ESC to quit.");
            using (var s1 = keyEvents.Subscribe(incrementKeyCount))
            using (var s2 = keyEvents.Sample(TimeSpan.FromSeconds(2.5)).Subscribe(displayKeyCount))
            {
                consoleKeyReader.ReadKeysUntil(ConsoleKey.Escape);
            }
        }