Hi,
I have an app with two threads. The main thread creates the GUI while another thread is created that connects to a web page and downloads some html files for parsing. When the needed information is extracted a Dataset is created containing a DataTable containing the information. When I try to bind the dataSet to a DataGrid on the GUI using the following:
this.curStatementGrid.SetDataBinding(myDataSet, "Customers");
I get an exception saying
System.ArgumentException: Controls created on one thread cannot be parented to a
control on a different thread.
at System.Windows.Forms.ControlCollection.Add(Control value)
at System.Windows.Forms.DataGridTextBoxColumn.SetDataGridInColumn(DataGrid va
lue)
at System.Windows.Forms.DataGridColumnStyle.SetDataGridInternalInColumn(DataG
rid value)
at System.Windows.Forms.DataGridTableStyle.SetInternalDataGrid(DataGrid dG, B
oolean force)
at System.Windows.Forms.DataGridTableStyle.set_DataGrid(DataGrid value)
at System.Windows.Forms.DataGrid.SetDataGridTable(DataGridTableStyle newTable
, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource, String
newDataMember, Boolean force, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource, String
newDataMember, Boolean force)
at System.Windows.Forms.DataGrid.SetDataBinding(Object dataSource, String dat
aMember)
at MyFormProject.MainForm2.connect()
I understand what this is trying to say to me but I cant figure out a way arround it. If I use a single thread It works fine but the entire GUI is locked up until all the web pages are got and parsed(this can take up to 15 seconds) Does anybody have any ideas.
Thanks
John Cleary
I have an app with two threads. The main thread creates the GUI while another thread is created that connects to a web page and downloads some html files for parsing. When the needed information is extracted a Dataset is created containing a DataTable containing the information. When I try to bind the dataSet to a DataGrid on the GUI using the following:
this.curStatementGrid.SetDataBinding(myDataSet, "Customers");
I get an exception saying
System.ArgumentException: Controls created on one thread cannot be parented to a
control on a different thread.
at System.Windows.Forms.ControlCollection.Add(Control value)
at System.Windows.Forms.DataGridTextBoxColumn.SetDataGridInColumn(DataGrid va
lue)
at System.Windows.Forms.DataGridColumnStyle.SetDataGridInternalInColumn(DataG
rid value)
at System.Windows.Forms.DataGridTableStyle.SetInternalDataGrid(DataGrid dG, B
oolean force)
at System.Windows.Forms.DataGridTableStyle.set_DataGrid(DataGrid value)
at System.Windows.Forms.DataGrid.SetDataGridTable(DataGridTableStyle newTable
, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource, String
newDataMember, Boolean force, Boolean forceColumnCreation)
at System.Windows.Forms.DataGrid.Set_ListManager(Object newDataSource, String
newDataMember, Boolean force)
at System.Windows.Forms.DataGrid.SetDataBinding(Object dataSource, String dat
aMember)
at MyFormProject.MainForm2.connect()
I understand what this is trying to say to me but I cant figure out a way arround it. If I use a single thread It works fine but the entire GUI is locked up until all the web pages are got and parsed(this can take up to 15 seconds) Does anybody have any ideas.
Thanks
John Cleary