473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Setting grid datasource within thread while table(source) is being filled...

VM
I'm trying to dynamically display the rows in a datagrid while filling the
datatable source. I'm doing it this way because we had already finished the
app but this section sometimes took so long that we had to add
multithreading. I do it with this code (this code is not in the class that
generates the form and the controls):

public DataTable OpenAuditAZMFileToView(string sFileName, ref DataGrid
dataGrid_auditAddress)
{
DataRow rowAudit;
sAuditRecord = sr.ReadLine();
while (sAuditRecord != null) //this runs 35,000 times. And the error
occurs with big files.
{
rowAudit = table_Audit.NewRow();
... //code Fills the row with appropriate data
table_Audit.Rows.Add (rowAudit);
SetGridDataSourceHandler handler = new
SetGridDataSourceHandler(this.SetGridDataSource);
_dataGrid_auditAddress.Invoke(handler, new object[]{DT_Audit});
sAuditRecord = sr.ReadLine();
}
}
private delegate void SetGridDataSourceHandler(object dataSource);
private void SetGridDataSource(object dataSource)
{
if (_dataGrid_auditAddress.InvokeRequired)
{
SetGridDataSourceHandler handler = new
SetGridDataSourceHandler(this.SetGridDataSource);
_dataGrid_auditAddress.Invoke(handler, new object[]{table_Audit});
}
else
{
this._dataGrid_auditAddress.DataSource = dataSource;
}
}

If I run the Invoke once after the table's been filled, it'll work fine. But
it I do it like this (set the grid source many times while the table's being
filled), I get different types of errors during runtime, such as "Object
reference not set to an instance of an object". And it only happens with
huge files (in my case, 35,000 lines).

Any help will be appreciated.
Nov 16 '05 #1
2 2022
> table's being filled), I get different types of errors during runtime,
such as "Object reference not set to an instance of an object". And it
only happens with huge files (in my case, 35,000 lines).


This is basically .NET's version of an Access Violation. You need to narrow
it down to which line of code this is occurring on and then find out either
why the variable is nil, or the object it was using has been destroyed.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 16 '05 #2
VM
But I don't think that's it because the errors show up when I'm dynamically
setting the datasource of the datagrid while the source (table) is being
filled. If the loop runs 35,000 times I'll be -adding row to table, setting
grid datasource- 35,000 times, and that's where I encounter the problem. If
I do it once after the whole table has been filled, it'll work fine.

"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
table's being filled), I get different types of errors during runtime,
such as "Object reference not set to an instance of an object". And it
only happens with huge files (in my case, 35,000 lines).
This is basically .NET's version of an Access Violation. You need to

narrow it down to which line of code this is occurring on and then find out either why the variable is nil, or the object it was using has been destroyed.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/

Nov 16 '05 #3

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

Similar topics

0
by: Robert Jarrett | last post by:
I have 5 tables (Names shortened to "A" through "E" for ease of this problem) each having the same first two fields: = T5 (key); and = T30 but otherwise different structures. In a many to many...
3
by: Marty McDonald | last post by:
I know about boxing & unboxing... but I'd like to know just a bit more. For instance, Dog is derived from Animal. Dog has a method called "Bark". Assume we're calling a method like this... Dog...
4
by: VM | last post by:
In the thread, I create a tableX and fill it with data. When I set the grid's source to this tableX, I get a compiler error "Controls created on one thread cannot be parented to a control on a...
0
by: MichaelR | last post by:
I'm getting a curious result from a module using WinInet on the client and IIS 6.0/ASP.NET on the server. Can't really tell if it's a client or a server issue. The client module uses...
2
by: astro | last post by:
can anyone tell me the syntax to get the datatable from a currencymanager? if this works: myCM = bindingContext(me.dataview1, "mytable") the how can I get the table given the...
4
by: hitendra15 | last post by:
Hi following is the code which sends file to the browser means user can download file, but the code generates error message Thread Being Aborted., will any one put their thoughts protected void...
1
by: Ezz | last post by:
I have an interesting problem...and its one of those where I know what I want but don't know how to ask it =) I have an eCommerce application that uses Paypal for its payment gateway. It is an...
4
by: Brian Wotherspoon | last post by:
Hi all, I'm using SQL Server 2000 SP3 to store data for real time transaction processing. I have set up replication to another server using a push subscription to give me immediate backup. ...
3
by: jediknight | last post by:
Having recently been asked to look into some bugs in one of our old web systems, I keep getting an error message in some try...catch statements that I've put in. Error message is Thread was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.