clearz Posted August 21, 2003 Posted August 21, 2003 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 Quote
clearz Posted August 21, 2003 Author Posted August 21, 2003 I know I can use Update to display the GUI but I have no control over it. Quote
*Experts* Volte Posted August 21, 2003 *Experts* Posted August 21, 2003 What code are you using for your HTML parsing? You may be able to use Application.DoEvents() to remove the delay. Quote
clearz Posted August 21, 2003 Author Posted August 21, 2003 http://www.devx.com/codemag/Article/10337/0/page/4 Tells me exactly what I want to know Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.