473,386 Members | 1,803 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,386 software developers and data experts.

Re: Cross-thread Operation Question

On Mon, 02 Jun 2008 17:14:31 -0700, NvrBst <nv****@gmail.comwrote:
[...]
Any insight or references about why some do/some don't, or what's safe
and what isn't would be appresiated (I tried searching but coudln't
find anythign).
The general rule is that if it's not one of the five members listed in the
docs (under Control.Invoke and other pages), you must use Control.Invoke()
or Control.BeginInvoke() to access _any_ member of a Control instance.

Now, as you've found, some members not in that list can be successfully
used without the cross-thread exception being thrown. One that I am
reasonably sure is okay is the Invalidate() method. As for the Text
property, looking at the implementation for Control, I can see that it can
cache the property value and so it stands to reason that if the value is
cached, you wouldn't get the exception.

Looking at both the Invalidate() method and the Text property getter, I
can see that the implementation treats the getter (but not the setter) and
the Invalidate() method as specifically cross-thread safe.

Now, as a general rule, I'm not a big fan of relying on the implementation
details. In theory, those could change at any time. But I think in this
case, the underlying reasons that these are safe (and the setter is not
safe) are likely to not change without some radical change within Windows
and/or .NET.

Which is a long way of saying that I think that you're okay not using
Invoke() when _getting_ the Text property. I might even go further and
say that for any member, if the cross-thread exception isn't thrown you're
probably okay. You might even consider filing a bug against the
documentation (http://connect.microsoft.com/) to emphasize to Microsoft
that they ought to be more explicit in their documentation about the
cross-thread exception and whether it's a reliable way to know whether
Invoke() is really required. There's definitely a lot of ambiguity on the
issue as things stand now.

Pete
Jun 27 '08 #1
0 1083

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

Similar topics

0
by: Web Science | last post by:
Site and Features: http://www.eigensearch.com Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
3
by: rollasoc | last post by:
Hi, Doing a bit of system testing on a Windows 98 laptop. (.Net 1.1 app). Did a bit of testing. Loaded a previously saved file. A gray box appeared with the text and buttons all white...
0
by: Web Science | last post by:
Site and Features: http://www.eigensearch.com Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
4
by: David Peach | last post by:
Hello, hope somebody here can help me... I have a query that lists defects recorded in a user defined date range. That query is then used as the source for a Cross Tab query that cross-tabs count...
0
by: Web Science | last post by:
Site and Features: http://www.eigensearch.com Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
7
by: Scott M. | last post by:
How can I disable the cross-site scripting check for one particular page of a site?
1
by: Rob Woodworth | last post by:
Hi, I'm having serious problems getting my report to work. I need to generate a timesheet report which will contain info for one employee between certain dates (one week's worth of dates). I...
6
by: Simon | last post by:
Hi All, An experiment i'm doing requires requires a synchronous cross-domain request, without using a proxy. I wondered if anyone had any ideas to help me achieve this. Below is what I have...
6
by: ampo | last post by:
Hello. Can anyone help with cross-domain problem? I have HTML page from server1 that send xmlHTTPRequest to server2. How can I do it? Thanks.
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.