Having a program manager, whose background is technical
writing, reply
with "You can have multiple UI threads" to a
question asking about "more
than one message loop per process" doesn't give me a
warn and fuzzy when
you've got seasoned developers like MVP Nicholas Paldino
saying
otherwise: "For any process, you are only supposed to
have one UI thread.
Doing otherwise will have unpredictable results. This has
been the model
for Windows programming for as long as it has been
around." [1] You can
certainly have more than one message loop or message pump
per process, but
that's not the same thing as having more than one UI
thread.
I believe it gets down to one message pump handling UI
messages--since
each message pump needs to be on it's on thread there can
be only one UI
thread.
[1] htt
p://www.thescripts.com/forum/thread228141.html
On Wed, 19 Jul 2006 09:43:30 +0300, Stoyan Damov
<stoyan.damov GMAIL.COM>
wrote:
>Host: MarkRi (Microsoft)
>Q: So it would seem to me that it is possible and that I
can have more
>than one message loop per process. However, is this
recommended? If
>so, what do I need to look out for?
>
>A: You can have multiple UI threads per process, but you
must call
>Application.Run() on each thread. You can also call
ShowDialog()
>instead of Run(). ShowDialog() creates a message loop.
The tricky part
>is that we don't support having those UI components
interacting
>natively -- you'll have to do your own marshalling
using
>Invoke/BeginInvoke.
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|