Ejemplo n.º 1
0
        public EditboxBasedConsoleOutputControl()
        {
            _editbox = new RichTextBox
            {
                BackColor   = SystemColors.Window,
                BorderStyle = BorderStyle.FixedSingle,
                Dock        = DockStyle.Fill,
                ReadOnly    = true
            };
            Controls.Add(_editbox);

            _outputThrottle = new ProcessOutputThrottle(AppendMessage);

            void AppendMessage(string text)
            {
                Debug.Assert(text is not null, "text is not null");
                if (IsDisposed)
                {
                    return;
                }

                Debug.Assert(!InvokeRequired, "!InvokeRequired");

                _editbox.Visible        = true;
                _editbox.Text          += text;
                _editbox.SelectionStart = _editbox.Text.Length;
                _editbox.ScrollToCaret();
            }
        }
Ejemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            KillProcess();
            if (disposing && _outputThrottle is not null)
            {
                _outputThrottle.Dispose();
                _outputThrottle = null;
            }

            base.Dispose(disposing);
        }