[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to end a modal run loop?

From: Andreas Heppel
Subject: How to end a modal run loop?
Date: Tue, 10 Sep 2002 11:12:13 +0200

Hi all,
I have the following problem.
My application starts an external task. The tasks progress is to be displayed 
in a small window unsing a progress indicator. The indicator is updated using a 
timer refiring until the external task is finished. Afterwards my application 
is allowed to proceed further. So far so good. This is not really hard to 
My problem now is that the window has a couple of buttons. If I use [NSTask 
waitUntilExit], the timer fires and the progress indicator proceeds but the 
buttons in my window don't respond to mouse clicks. Thus, I start a modal 
session for this window using [NSApplication runModalForWindow:]. This works 
fine up to the point where the external task finishes. My timer sees this and 
stops the modal loop [NSApplication stopModal]. Unfortunately, the procedure 
having started the loop (and is still waiting for it to finish) does not 
recognize this until the mouse pointer is moved into my application, i.e. the 
application receives an event. This behaviour is absolutely inacceptable for my 
application because it needs to proceed without any user interaction inbetween 
(even if it is just moving the mouse pointer into the window).
If I have understood the NSApplication/NSRunLoop/GSDisplayServer code 
correctly, the application waits in [NSApplication runModalSession:] 
indefinitely for an event. Only after an event occurred, it realizes that the 
modal session has finished. Why is this so?
Is there any other way to keep my progress window responsive to eventual mouse 
clicks on the one hand and on the other hand have my application detect that 
the modal session has ended (after stopModal).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]