High performance output window

  • Thread starter Thread starter Anthony Brien
  • Start date Start date
A

Anthony Brien

I have a puzzling situation in a C# application and hope someone has an
idea how to fix it:

I have an application with a LogService for reporting errors, warnings
and other messages. The output is sent to a log window just like Visual
Studio's output window. The output window is in its own separate thread
so that it updates even when my UI thread blocks (I know it's not the
best way of doing things, but making every long operations in my UI
into worker threads is unfeasible at this time).

When my LogService receives messages, it calls BeginInvoke onto my log
window to pass the message information. The log window accumulates the
messages in a queue to avoid updating the UI too many times a second (I
use a RichTextBox). It dumps the messages at most once per second.

What's odd is that when I bombard my log window for example in 2 sec.
with thousand of messages, after 2 seconds my main window starts
responding again (which is fine), but the log window gets the messages
added at a crawling speed and it takes it 20 sec to finish.

Another odd thing is that when I move my mouse or do other things in my
main window, the log window suddenly wakes up and processes the
remaining log messages rapidly. If I stop moving the mouse, the log
window goes back to slow mode. It's as if my main form being idle
affects my log window in the other thread.

Does anyone have any explanation for this?

Also, does anyone know an efficient control for dumping thousands of
lines of text quickly? I've tried the RichTextBox, TextBox, ListBox,
and they all have their limitations. I'd like something like Visual
Studio's output window.
 
I'm using console for this together with external file.
When done properly seems to be quite efficient
 
Back
Top