0

I have FlowLayoutPanel with multiple small DataGridView controls. I feed the data sources of the controls in background thread. This IS NOT the source of the problem. The grids have to be updated in "real time", so I update them at least once a second, for testing I set 100ms per update. It works, however UX is very choppy and unresponsive. When I try to move controls on screen the movement is not smooth.

When I disable a single line in code:

control.DataSource = items;

it runs perfectly smooth with no hickups, but of course I have no data in grids. I have data read from database, processed in code, only not displayed. All those operations don't take much CPU or IO time, my machine is almost idle.

What can I do to stop grid updates from blocking UI? Invoke or BeginInvoke does not help. The same thread, the same message loop. Is there a way for non-blocking update?

Increasing update interval doesn't help much - the hickup occurs less often, but it ALWAYS occurs which is very disturbing when a user tries to move a control from one window to another. The feature of draggable controls is crucial to the app. Is there something to be done to improve UX except creating own, low-level, optimized DGV?

No, I won't paste my code here, it's too huge and most of it is completely irrelevant to the problem. The problem is simple. I got data ready in memory DataSet objects. All I need is to pass it to DataGridView controls without UI hickups on "dgv.DataSource = myDataTable" operations.

Harry
  • 4,524
  • 4
  • 42
  • 81
  • Can you give us a few numbers? How many DGVs with about how many records in total are we talking about? – TaW Jun 09 '14 at 09:31
  • Up to 100 DGV, up to 30k total rows distributed between all controls. I test it on 15 DGV with 10k rows. I think it would be best to hold update after receiving mousedown on main form, until mouseup is received. – Harry Jun 09 '14 at 11:26
  • Hm, that's like, not totally nothing for a winforms gui. I ain't no WPF fan, but that might call for a different platform.. – TaW Jun 09 '14 at 11:28
  • Do you think WPF would be faster? If so, I should seriously consider it. – Harry Jun 09 '14 at 11:34
  • Yes. It uses Direct3D instead of GDI+ which brings it a few decades closer to today's hardware. IMO it is a bitch to learn for an old man like me, but most certainly well worth it! – TaW Jun 09 '14 at 11:43
  • Also: WPF is all about Data Binding so a job like the one you need done is its home turf. Just don't ask __me__ to help ;-) But maybe if you whisper @HiCore three times..?? – TaW Jun 09 '14 at 11:56
  • @TaW I still fail to understand why you reject current technology so badly. You're just like myself, still using a [Nokia 1100](http://www2.pcmag.com/media/images/130725-nokia-1100.jpg?thumb=y) phone in 2014... – Federico Berasategui Jun 09 '14 at 14:04
  • @Harry you might want to check out [this short clip](http://www.youtube.com/watch?v=D3Y6DnFpHCA). BTW, WPF's performance gain here is not related to the rendering stack (DirectX versus GDI), but on the fact that WPF has built-in UI virtualization (enabled by default), while winforms does not, and it requires (as much as anything else in winforms) a bunch of horrible hacks in order to activate it. – Federico Berasategui Jun 09 '14 at 14:05
  • Thank you guys, this is it, WPF is the way to go. This is my last project done with WinForms ;) I have to finish it, because I would almost certainly fail to meet the deadline if I started to learn now. But it seems worth learning in my spare time anyway. I made some simple apps with WPF, it doesn't look like some rocket science :) – Harry Jun 09 '14 at 14:42

0 Answers0