473,804 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.
myDataGridOnThe Form->SetDataBinding (myDataSet, S"TableName" );

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

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

System::Void buttonCreateTab le_Click()
{
....
TaskDelegate* myTaskDelegate = new TaskDelegate(th is, fnc_Fill_Grid);
myDataGridOnThe Form->BeginInvoke(my TaskDelegate );
}

System::Void fnc_Fill_Grid()
{
.....
myDataGridOnThe Form->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
0 1033

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1521
by: Alex | last post by:
Hi all... I have a DataGrid bound to a DataTable. My DataTable gets updated programmatically as it contains the status of a number of worker threads. Each "main" worker thread launches a number "child" threads, so displaying the status of these in a DataGrid is ideal - one row for each "main" thread, one column for each "child" thread. However, some of these threads take a while to update their status, so I'd
2
1704
by: John Smith | last post by:
Hey folks, I'm writing a Windows application which has many forms which have Datagrids on them to display data. These datagrids will not be editable in anyway. They are there to just view the results of a query (and perhaps double click on a row to open a new form). Additionally, the queries will often involve the use of 5 or more tables. Because efficiency (both speed and memory) is the primary concern what is the best method to...
0
307
by: Abra | last post by:
Is it possible to fill a ADO.NET dataset incrementally ? (I mean to call the DataAdapter Fill() method several times, as I did not found a Add() method) I would like to call in a background thread the Fill method several times, only with a limited number of records, as I have very many records in the database. The dataset is attached to a control (listbox) and I would like that the listbox appears quickly on screen with some 50 records...
2
1779
by: wackyphill | last post by:
I have a long running query. I want the results in a DataGrid. I'd like the grid and form to be responsive and fill up w/ rows as the result set is read into a dataset that is the datasource of the grid. Possible? If so, how should the thread handle updating the grid's datasource and have the grid reflect the changes w/o waiting till the thread finishes? Any example would be greatly appreciated. Thanks.
3
2397
by: mahtan | last post by:
Please help I have the problem that when I change the data in a Windows.Forms.DataGrid by a separate thread the following Exception is thrown: ThreadSystem.NullReferenceException in system.windows.forms.dll I can't catch this Exception and it only occurs when I
2
1957
by: Lucas Tam | last post by:
Hello, I am trying to update a datagrid via an async call, but the datagrid shows up empty. I've checked the datatable - there are indeed rows in it... Here is my code:
2
12107
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
The auto-generated line of code to fill a DataGridView once it is placed on the designer surface in VS2005 is typically: this.xyzTableAdapter.Fill(this.myDataSet.MyMember); But if the query takes a long time to run, this freezes the UI (in a Windows Forms application). What is the best practice for filling a DataGridView without freezing the UI?
7
1252
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my Windows application, I'm using thread, and I've 2 questions: 1. I read that it's not recommended to use Thread.Abort(), so what is the best way to close the thread, in case the user wants to cancel or the thread is finished and i want to close my application? 2. in my Thread I'm creating a dataGridView with DataTable as dataSoruce, and I've problem with the scroll bars, I see the scroll bars but both of the
2
6600
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the itemsource shows the info is there. Know if I click on the child cell and then click back on the...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10359
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9177
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.