KnNeeded
July 26th, 2005, 03:11 AM
Hi Everyone,
I have a very strange problem that I am having troubles of thinking a way around.
I have 3 threads other than the main application thread that do independant continous work (mainly monitoring sockets). I was trying to implement a message mechanism back to an output window in the main application and are getting some issues. I have created a Server class that simply provides the subscription to the message event and a method for creating a new message. I have let the main form own this class instance and passed a reference to it in each thread class. I then have created a window that gets passed the same class instance of the message server and have got this form to prescribe to the event.
The problem is when I go to add the message to the list view. When the line Mylistview.Items.Add executes it takes over 1 second to add a single item for it to complete (I have checked for exceptions - none are forth coming), this creates a problem because a burst of messages makes the whole application grind to a halt and my communication timers think the communication has timed out (Default 3 seconds). If I blow my communication timeout timers to 20 seconds it is slow but it all works ok. If I block out the single listview add line and keep my timers at my normal 3 second timeout period it all works ok.
I have only just started to add this functionality into the application and I want the output window to display a lot more messages to the user, based on the couple I have added so far there is too much of a performance price to pay.
Should I be using a simply list box or text box instead of a listview? Any suggestions to better manage sending messages to the user from multiple threads?
Thanks in advance
KnNeeded
I have a very strange problem that I am having troubles of thinking a way around.
I have 3 threads other than the main application thread that do independant continous work (mainly monitoring sockets). I was trying to implement a message mechanism back to an output window in the main application and are getting some issues. I have created a Server class that simply provides the subscription to the message event and a method for creating a new message. I have let the main form own this class instance and passed a reference to it in each thread class. I then have created a window that gets passed the same class instance of the message server and have got this form to prescribe to the event.
The problem is when I go to add the message to the list view. When the line Mylistview.Items.Add executes it takes over 1 second to add a single item for it to complete (I have checked for exceptions - none are forth coming), this creates a problem because a burst of messages makes the whole application grind to a halt and my communication timers think the communication has timed out (Default 3 seconds). If I blow my communication timeout timers to 20 seconds it is slow but it all works ok. If I block out the single listview add line and keep my timers at my normal 3 second timeout period it all works ok.
I have only just started to add this functionality into the application and I want the output window to display a lot more messages to the user, based on the couple I have added so far there is too much of a performance price to pay.
Should I be using a simply list box or text box instead of a listview? Any suggestions to better manage sending messages to the user from multiple threads?
Thanks in advance
KnNeeded