Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...