By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

How to Fill a DataGrid by a Background Thread at VC++ .NET?

P: n/a
Hello Developers,

I would like to fill a data grid on my "Windows Forms (.NET)" by a
background thread.

I read some data from a binary file. With the information read from this
file, I create Columns and Rows dynamically, then I fill them. I can do this
operation. But, when the numbers of rows and columns are much, my application
uses the 99% of CPU and stops working for other works. Fot this reason, I
tried to assign this job to a background-running thread that I create it.
But it throws exception when I assign the data set to my datagrid.
myDataGridOnTheForm->SetDataBinding(myDataSet, S"TableName");

Then I used the BeginInvoke( ) method, which is working, as follows:

....
__delegate System::Void TaskDelegate();

System::Void buttonCreateTable_Click()
{
....
TaskDelegate* myTaskDelegate = new TaskDelegate(this, fnc_Fill_Grid);
myDataGridOnTheForm->BeginInvoke(myTaskDelegate );
}

System::Void fnc_Fill_Grid()
{
.....
myDataGridOnTheForm->SetDataBinding(myDataSet, S"TableName");
}

Above code is working. I checked the Thread IDs. I noticed that the Main
Thread of Application and BeginInvoke()'s worker thread ID is same.

Can you kindly explain me How To Fill a DataGrid With a Created-Thread?

Thanks in advance.

Bil Muh
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.