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

DataGrid Cross Thread Access

P: n/a
TFS
Hi,

I know the topic of cross-thread operations from the UI has been addressed
several times, but if anyone could provide some insight for my particular
scenario, I would be thankful...

Using Visual Basic (VS 2005 Beta 1)

In a Public class X, I have a TCP connection setup to parse and dump data
into a DataTable

On a Windows form I have a DataGrid and a button. When I click the button, a
new instance of the class X is created, the TCP connection is opened, and the
DataGrid's DataSource property is set to the the DataTable of class X.

I'm getting an 'Illegal Cross thread operation' being thrown from the class
saying that the DataGrid is being accessed on a thread other than the one it
was created on.

How do I code for this (seemingly simple) scenario?

Much thanks,

-Todd
--
Management Analytics, Inc.
http://ManagementAnalytics.com
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

http://msdn.microsoft.com/msdnmag/is...asicInstincts/

Ken
-------------------
"TFS" <Todd "at" ManagementAnalytics "dot" com> wrote in message
news:A7**********************************@microsof t.com...
Hi,

I know the topic of cross-thread operations from the UI has been addressed
several times, but if anyone could provide some insight for my particular
scenario, I would be thankful...

Using Visual Basic (VS 2005 Beta 1)

In a Public class X, I have a TCP connection setup to parse and dump data
into a DataTable

On a Windows form I have a DataGrid and a button. When I click the button, a
new instance of the class X is created, the TCP connection is opened, and
the
DataGrid's DataSource property is set to the the DataTable of class X.

I'm getting an 'Illegal Cross thread operation' being thrown from the class
saying that the DataGrid is being accessed on a thread other than the one it
was created on.

How do I code for this (seemingly simple) scenario?

Much thanks,

-Todd
--
Management Analytics, Inc.
http://ManagementAnalytics.com
Nov 21 '05 #2

P: n/a
TFS.

Be aware that the result of your thread in this case is only that it takes
some more time, however your user has the change to close the application.
(If you have set the right properties for that).

Than you can in my opinion create a seperated new dataset which you have
placed modaly and set that as the new datatasource when the thread ends.

Another option is in my opinion by first setting the datagrid.datasource to
nothing.

I hope this helps,

Cor

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.