471,310 Members | 985 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Multithreaded DataGrid update issue

I have an app that spawns several threads to concurrently download web
pages.

The threads that download the pages call a method in a tab page to update
the information in a DataGrid. The method is as follows:

internal void UpdateItem(string url, QueueItemStatus status, int pct)
{
if (InvokeRequired)
{
Invoke(new ItemUpdateDelegate(UpdateItem), new object[] {url,
status, pct});
}
DataRow[] rows = _dt.Select("URL='" + url + "'");
if (rows == null || rows.Length == 0)
{
Debug.Assert(false, "URL not found.");
return;
}
rows[0]["Status"] = status.ToString();
rows[0]["Pct"] = pct;
_dt.AcceptChanges();
}
As you can see, I'm handlign the InvokeRequired stuff (did I screw it up)?
If I go to a tab page other than the one with the grid, everythign works
fine.. If I've got the grid displayed, on the other hand, it sometimes
throws a NullReferenceException in the framework's
Control.PaintWithErrorHandling() method.

The URL always exists and only 1 row is ever returned. The Debug.Assert() is
never hit. There are no grid-related event handlers in the tab page code.
It's just a very basic grid.

Am I missing something? I mean, this all seems straightforward, but I can't
for the life of me see what's wrong here.

Pete
Feb 23 '06 #1
0 1054

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Pam Ammond | last post: by
4 posts views Thread by Glenn Owens | last post: by
5 posts views Thread by Chris | last post: by
4 posts views Thread by siaj | last post: by
2 posts views Thread by Steve Pierce | last post: by
9 posts views Thread by rn5a | last post: by

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.