Re: display message in work thread
Hi Mihajlo,
I think this is turning into one of the "religious" discussions :o) There
are obviously lots of ways to do things. I think you'll find that the
general consensus is that popping up messages from worker threads can lead
to some trouble, but it probably works most of the time if you really want
to do it. I have a specific problem where I have an API that I use that
creates it's own thread then does a callback into my thread (not my favorite
paradigm). Anyway, when it calls back it technically is coming from a
different process so if I try to pop up a dialog box using a resource (like
a string) since I would never put in a static string, it either asserts if
there is no string resource with the same number, or it displays the string
it happens to find which is probably wrong.
It took me a while to debug through this problem once and because of that I
always use the send message method (to the UI thread) whenever I need to
display or use any resource. Of course, my situation was pretty specific.
Tom
"Mihajlo Cvetanovic" <mcvetanovic@gmail.nospampls.com> wrote in message
news:e9Uv0RsIIHA.588@TK2MSFTNGP05.phx.gbl...
Joseph M. Newcomer wrote:
Because I would never consider a thread that required user interaction to
be a
well-designed thread. Worker threads do not interact with users.
It seems to me that David and you made generalized conclusions based on
some specific situation. I agree that worker threads should do the work,
but if they can't (do the work) and must wait on user then there's no
reason to interact with user through some other thread. The only issue I
see right now is how to finish the thread if it has message box open (from
Tom's post). It may be a good idea to have a custom made message box to
handle this.
Creating windows in different threads is probably a bad idea in general
case, but I believe that there are cases where window in worker thread
works just fine without unwanted side effects.