0

I have a C# winform application that has 4 distinct user controls on the screen. Each of these user controls contains a datagridview control. When the user updates a cell value in any one of these 4 control I raise a custom event sending the value of the cell to a 5th form on the screen.

This 5th form is very similar to an Excel spreadsheet. The 5th form must show the new value sent on it's pane/window. The issue is not in sending the data from any of the 4 user controls, that works and is reflected on the 5th form.

However, when the event to send data is raised it stops the user input for a few seconds. I think the 5th form is busy updating the cells. So my question is if I implement a message queue or something similar (wcf) for sending the new values to the spreadsheet like control, will that 5th control pickup the data (maybe on Application Idle event) and not slow down the end user input on any of the 4 main controls or will I just see the same issue because of the forms all running in the same UI thread. I did do a some testing to see if it's any quicker if the 5th control is hidden from view, but I see the same results. Also I did some timing checks and it is definitely after I raise the Value_Changed event that the system is becomes very slow.

Any ideas on how to approach and solve this issue?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Rick
  • 648
  • 1
  • 11
  • 25
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Mar 25 '14 at 21:56
  • What does your profiler tell you? – Rowland Shaw Mar 25 '14 at 21:56
  • Impossible to say without more information about what that 5th control is doing. Does it have to do some processing before it updates the cells? If so, then you should have an async task do the work, and then update the cells after the async task completes. – Jim Mischel Mar 25 '14 at 22:35
  • Rowland, I have VS 2010 Professional it doesn't have the profiler. :( – Rick Mar 25 '14 at 23:33
  • Jim, That might be the case, but it's that 5th control is very responsive when a user is entering data. So I'm surprised to see such a delay when an event is raised and sends the data programatically. Just thought that a maybe the main thread is too busy doing other tasks when the event is being fired. – Rick Mar 25 '14 at 23:38

1 Answers1

1

Perhaps you should try a simple Control.BeginInvoke() to pass the data with a structure. This will ensure you don't have threading issues between objects AND is asynchronous.

Guillermo Prandi
  • 1,537
  • 1
  • 16
  • 31
  • I gave that a try and it helped uncover the real issue. When I checked the timing after your suggestion it basically took zero milliseconds. But the form was still slow. It turns out that when I'm sending values to the spreadsheet, I shouldn't have the event that listens for spreadsheet change_values enabled back to my control. Yea, dah! Really?! Thanks! – Rick Mar 28 '14 at 18:10