0

Im using model view presenter pattern in my winforms app. I have to bind some data to the gridView. I want to get the data in the separate thread. This is what I do:

In presenter I call: BackgroundWorker_GetDataSourceFromFile. In this method I create datasource and call View.SetDataSet.

In the view SetDataSet:

DsGridView.DataSource = value;
DsGridView.Refresh();

It is ok except scrollbars. They appear but doesnt work :/

Has anyone of you had such a problem?

Thanks in advance

gruber
  • 28,739
  • 35
  • 124
  • 216
  • You can't use WinForm Controls on a thread other than the UI thread. See http://stackoverflow.com/questions/2367718/automating-the-invokerequired-code-pattern and http://stackoverflow.com/questions/5815948/c-sharp-cross-thread-call-problem – DrKoch Jan 11 '15 at 17:59
  • But I dont get any exception so it means that I can, doesnt it? – gruber Jan 11 '15 at 18:06
  • No, it doesn't. Multi-threading errors lead to all kinds of unpredictable behaviour. – DrKoch Jan 11 '15 at 18:08
  • Use InvokeRequired like in this example: [http://stackoverflow.com/questions/5815948/c-sharp-cross-thread-call-problem][1] [1]: http://stackoverflow.com/questions/5815948/c-sharp-cross-thread-call-problem – DrKoch Jan 11 '15 at 18:09
  • Ehhh, in my case I run another thread in my controller not view and then simply set DataSource of my View so its different problem. I dont get cross-thread call error like in the example you gave – gruber Jan 11 '15 at 18:21

0 Answers0