• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1279
  • Last Modified:

Datagridviews hang application.

Ok.  So here's the pickle.

When my application is executed in debug mode, everything works as I would expect.  However, when executing it outside the IDE, I get a couple of weird behaviors that I think are related.  
Here's the set up for the datagridviews in question.  

They both use their own bindingsource controls which point to their own tables in the same dataset.  
datagridview1 (dgv1) underlying table is populated using table.copy form another table.  It gets roughly 2000 rows.
datagridview2 (dgv2) underlying table is then populated from within a backgroundworker adding rows via .add(newrow).  It gets roughly 17000 rows.
Both of these dgv's are located on a tabpage that isn't visible until the backgroundworker is complete.  

Note:  I remove and add the tabpages of the tabcontrol based on a combobox selection.  

Behavior 1)  If I close the application (the backgroundworker process has ended), without moving to their tabpage, the application hangs for several minutes when trying to dispose either of them.
Behavior 2)  If I switch to their tabpage the first time, the application hangs when adding the tabpage to the tabcontrol for several minutes before the tabpage displays any of its controls.  But if I then close the application, it closes immediately without hanging during their dispose.

When troubleshooting Behavior 1, I can successfully dispose the datatable, dataset and binding source prior trying to dispose the dgv's, but the dgv's will still hang.  Also, if I try to set the datasource to nothing or to do a dgv.columns.clear it will hang.  dgv.rows.clear is successful.

This makes me think it has something to do with the columns.  I've tried disabling the only size property enabled, the AutoSizeColumnsMode, which is set to fill, but the problem persists.  

I thought it might be thread related, but all of my threads have completed and returned to the main control before I try any of these steps.  I'm at a loss how to proceed.
  • 2
1 Solution
rogerardAuthor Commented:
Another note for Behavior 2:  Once the dgv's are displayed the vertical scroll bars are non-functional and their gdi is corrupt.  I'm still able to cycle through the values using the mousescroll or arrows on the keyboard.
rogerardAuthor Commented:
Ok.  I figured it out.  I'm sure it's thread related, but definitely has to do with datatable population.  I set the dgv's datasource to nothing prior to launching the routines to populate their data, then reassigned their datasources to their bindingsource controls once the datatables were populated.  Now there are no hangs.


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now