Message queue in modeless dialogs

G

Guest

Hi, i have a multithreaded application which uses forms and i have a worker
thread that has to create a modeless dialog to monitor some of the operation
which it has to do. The problem is that if you create the dialog and call
show() from the thread this dialog wont't have a message queue and will
become unresponsive. I found in a page that you have to create the dialog in
the main UI thread.In that case the message queue of the main form will be
shared among the main form of my application and the modeless dialog i have
created, but there is a problem. If one of them hangs up the other too will
hang. The problem is that my application hangs at one point and i dont know
exactly the reason , the only thing i know is that it has to be something
like a deadlock that causes one of the forms become unresponsive.
I want the modeless dialog to have its own message queue independent from
the main UI message queue, ¿how i can do that? i have tried to create a new
thread which executes application.run again as i have read that this method
creates a message queue for the thread who calls it but the result was not
the expected one: my modeless dialog runs ,be sure of it but when i call
application exit in the thread of the modeless dialog all the application
exit, not only the thread which i was pretending to be th ethread of teh
dialog, follow me?
Any ideas about this?
 
J

Jeff Pek \(Autodesk\)

Why not create the modeless dialog in your main thread, but then kick off a
worker thread to actually do the work you're doing?
What do you mean by "if one of them hangs up" -- why would they do that? The
forms themselves won't hang up -- though perhaps what's happening in the
worker thread could stop...

jp
 
G

Guest

I do that instead.
I have a worker thread that is doing some operations and the user can ask it
to show a monitor to show the progress of its work.The worker thread do an
invoking on the main UI thread to create the modeless dialog so it shares the
message queue of the main form of the application. So the dialog is created
in the main thread really. The worker thread updates the contents of the
dialog periodically doing invoking operations on it. The problem is that when
i execute my program it hangs when the modeless dialog has to be repainted
(when i for example occlude part of its client area and later discver it
again) and i dont know why. It looks like some kind of deadlock but im not
sure.Makes all of this sense to you? have you been in a similar situation?
 
J

Jeff Pek \(Autodesk\)

No, I haven't seen that. You could also try a BeginInvoke to update the main
UI; this wouldn't block the invoker.
- Jeff
 
G

Guest

BeginInvoke dont resolve the problem so then it has not to be with the
blocking behaviour of the Invoke method. The fact is that my modeless dialog
only blocks when i moves it, sometimes later and sometimes sooner. If i leave
the dialog quiet the application dont hangs.MMMM strange
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top