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.