コード例 #1
0
        /// <summary>
        /// This method processes input received on the console
        /// </summary>
        /// <returns></returns>
        public string ProcessInput()
        {
            currentProcessingThread = Thread.CurrentThread;
            Console.CancelKeyPress += InterruptProcess;

            isProcessingCompleted = false;

            cmdhistory.CursorToEnd();
            DisplayText("");
            cmdhistory.Append("");

            while (!isProcessingCompleted)
            {
                try
                {
                    Handlekeys();
                }
                catch (ThreadAbortException)
                {
                    HandleException();
                }
            }

            Console.WriteLine();

            Console.CancelKeyPress -= InterruptProcess;

            if (buffer == null)
            {
                return(null);
            }

            string result = buffer.ToString();

            if (result != "")
            {
                cmdhistory.Accept(result);
            }
            else
            {
                cmdhistory.RemoveLast();
            }

            return(result);
        }
 /// <summary>
 /// Initilaize history
 /// </summary>
 internal static void InitializeHistory(string initial)
 {
     historySerial.Append(initial);
     historySerial.CursorToEnd();
 }