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

Background Threads, BeginInvoke, etc...

P: n/a

Hello

The book "C# Black Book" chapter about Threads says that a
"background thread" cannot communicate directly with a
visual element, e.g. a label, and thus has to use the
BeginInvoke method, otherwise an exception will be thrown.

The book also says: "Because a thread has its own process space,
the addres of an object in one thread is not useful in another
thread."

However, I've experimented, and it seems perfectly possible
to update e.g. a label.Text from a background thread. (I.e. for
any sort of thread.)

Also, I don't understand what distingueshes a "background" thread
from a vanilla "thread". I mean, isn't the priority set with the
property Priority? A "background" thread is to me a thread with
a low Priority.

Therefore, I have these questions to you Thread Gurus:

1. What exactly does the thread property IsBackground do, i.e.
what distingueshes a backgound thread from a "vanilla" thread
with low priority?

2. Is there any reason to use the BeginInvoke method other than
synchronisation? (I.e. I assume if BeginInvoke is used, the
result is automatic synchronisation.) Does background threads
differ from "vanilla" threads for this particular issue?

3. Does the statement "Because a thread has its own process
space, the addres of an object in one thread is not useful
in another thread" make any sense whatsoever? (It perfectly
possible to acces objects created in one thread from another
thread, and all syncronisation obviously has got to do with
this being done in a controlled way...) So what could he
possibly mean?

Thanks in advance for any help on this!

/Gomaw

Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.