protected void MessageHandler(MessageFormater messageFormater) { if (InvokeRequired) { BeginInvoke(new MessageHandlerDel(MessageHandler), new object[] {messageFormater}); } else { listBoxMessages.SuspendLayout(); addMessageLine(messageFormater); if (listBoxMessages.Lines.Length > 5000) { removeFirstFromListBox(); } scrollToEndOfListBox(); listBoxMessages.ResumeLayout(true); } }
private void addMessageLine(MessageFormater messageFormater) { listBoxMessages.SelectionColor = messageFormater.MessageColor; listBoxMessages.AppendText(messageFormater.Format()); }