public TextBoxAppender(RichTextBox textbox) { this._textBox = textbox; WriteLog = (msg, level) => { try { if (_screentextLength > 0xFFFF) { _textBox.Clear(); _screentextLength = 0; } _textBox.SelectionColor = _logColors[level.Value / 10000 - 4]; _textBox.AppendText(msg); _screentextLength += msg.Length; } catch { } }; }