473,327 Members | 2,112 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,327 software developers and data experts.

Threading and datagrid updates good idea?

VM
Is it possible that a thread that updates a grid give me problems? For some
reason, when the for loop is really big (30000+ rows in grid), I get "Object
reference not set to an instance of an object" or "External component has
thrown an exception" in some rows. And it always happens in the first few
records (rec. 30-40 when I'm stepping through the code or rec. 10-18 when
I'm not).

This is the code:

private void runProcess()
{
ThreadStart thr_markGrid = new ThreadStart(markAuditGrid);
Thread AZMThread = new Thread (thr_markGrid);
AZMThread.Start (); //starting the thread
}

private void markAuditGrid()
{
for(int i=0;i<iRows; i++) //iRows = 35000 - number of rows in grid
{
if(dataGrid_auditAddress.IsSelected(i) == true)
{
dataGrid_auditAddress[i,5] = "MARKED";
}
}
}
Nov 16 '05 #1
4 1192
VM <vo******@yahoo.com> wrote:
Is it possible that a thread that updates a grid give me problems?


Yes. A DataGrid is a UI control, and as ever, you shouldn't do anything
to the UI except within the UI thread.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
VM
The reason I added this thread was so the application could respond to other
user events while the grid was beig updated. If I want to do this update
within the UI thread, how would you do it?
Any links that talk about working with the UI thread would be agreatly
appreciated.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
VM <vo******@yahoo.com> wrote:
Is it possible that a thread that updates a grid give me problems?


Yes. A DataGrid is a UI control, and as ever, you shouldn't do anything
to the UI except within the UI thread.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
VM <vo******@yahoo.com> wrote:
The reason I added this thread was so the application could respond to other
user events while the grid was beig updated. If I want to do this update
within the UI thread, how would you do it?
If you're basically doing a lot of stuff to the UI (and changing up to
35000 rows is a lot of stuff) then it's going to take some time.
Any links that talk about working with the UI thread would be agreatly
appreciated.


I don't have any links on hand, I'm afraid, although I'm sure there are
lots of pages around.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

do what you'd normally do w/o spinning off another thread. if you are concerned that your program will temporarily freeze while doing all that work, then maybe you should rethink about displaying 35000 rows in the UI. :
----- VM wrote: ----

The reason I added this thread was so the application could respond to othe
user events while the grid was beig updated. If I want to do this updat
within the UI thread, how would you do it
Any links that talk about working with the UI thread would be agreatl
appreciated
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in messag
news:MP************************@msnews.microsoft.c om..
VM <vo******@yahoo.com> wrote
Is it possible that a thread that updates a grid give me problems
Yes. A DataGrid is a UI control, and as ever, you shouldn't do anythin

to the UI except within the UI thread
-

Jon Skeet - <sk***@pobox.com>> http://www.pobox.com/~skee
If replying to the group, please do not mail me to


Nov 16 '05 #5

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

Similar topics

0
by: Zuel | last post by:
Sup everyone! I wrote this code for Tomcat appserver but I am told from an associate that it has threading issues. The basic idea is to store a read only data table for everyone to use. It...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
2
by: Stephan Steiner | last post by:
Hi I'm using several DataTables in my program which are updated periodically. At the same I have those tables bound to DataGrids in my GUI. So far I've been doing all the processing in the same...
7
by: Tom B | last post by:
I've written the code below to try and figure out how threading works. My assumption is that when starting a new thread it would run at the same time as the original thread. Am I wrong? I've...
3
by: Elliot Rodriguez | last post by:
Hi: I am writing a WinForm app that contains a DataGrid control and a StatusBar control. My goal is to update the status bar using events from a separate class, as well as some other simple...
4
by: trialproduct2004 | last post by:
Hi all i am having application in C#. here what i want it to update one datagrid depending on particular value. I want to start minimum of 5 threads at a time and all these threads are updating...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
2
by: shumaker | last post by:
I did have a save button for a datagrid that is bound to a tableadapter, but I wanted to remove the button and instead save updates everytime a user finishes editing a row. So I moved the update...
4
by: Ty | last post by:
Hi all Short version of my problem: i have a Datagrid (Flexgrid from ComponentOne) with a Datatable as source. I need to search a row in the datatable, using a primary key column in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.