none
application crashing on high IO theshold RRS feed

  • Question

  • Hello Boys and Girls,

    I am sitting with a BIG BIG problem and I am hoping someone is able to spread some light on it. I have an application(C#, WPF). This app, is used for logging info, from a java server, to the screen(ListBox).

    When the IO load becomes too big, the window just dies, without any warning or exception, and I am trying to find out how to prevent it from crashing.... Some sample code of where i think it should be crashing:

     

            public void log(String message)
            {
                consoleListBox.Dispatcher.Invoke(new logMessageDeleg(logMessage), new object[] { message });
            }

            private void logMessage(String message)
            {
                if(current_line_nr > MAX_NR_LINES)
                {
                    int counter = 2000;
                    while(counter > 0)
                    {

                        consoleListBox.Items.RemoveAt(0);
                        current_line_nr = current_line_nr - 1;
                        counter = counter - 1;
                    }
                    consoleListBox.Items.Add("########## Maximum number of lines (12,000) reached, trimmed to 10,000.");
                }

                consoleListBox.Items.Add(current_line_nr +"--" + message);
                consoleListBox.ScrollIntoView(consoleListBox.Items[consoleListBox.Items.Count - 1]);
                current_line_nr = current_line_nr + 1;
            }

     

    Monday, March 29, 2010 2:53 PM

All replies

  • Hi Everyone,

    I posted this question yesterday, with no luck of anyone answering back. I am just replying - to maybe attrack the attention of someone who can help me. Still stuck on this one, and do not know how to move forward. Any discussion welcomed....

    Tuesday, March 30, 2010 8:41 AM
  • I am giving up on this one... I don't think the control has been designed with such a high throughput in mind.
    Wednesday, March 31, 2010 8:32 AM
  • Hi harriet_001,

    I have tested a similar code and cannot reproduce the issue.

    Based on your code, I guess the log method is called in several threads. If so, the possible cause of the issue is the synchronization of these threads. You need to check if some values or objects are shared by the threads, such as current_line_nr. If so, you need to lock the related object:
    http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx

    Let me know if this does not help.
    Aland Li


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    Friday, April 2, 2010 3:54 AM
    Moderator
  • Hi Aland,

    Thank you for your reply. I made the code more efficient, by replacing Dispatcher.Invoke(synchronous) with Dispatcher.BeginInvoke(asynchronous). This did improve the performance, but the application still crashed, and I ended up with a solution whereby I would only allow the window to be active for 15minutes, before dying by itself. The user then needs to open the window again. I will have to work on a better solution though, and I would appreciate your input...

    There is only one call to the log(...) method, but it is called at a very high rate.

    Monday, April 12, 2010 10:15 AM