Re: Call back to the run loop?
Re: Call back to the run loop?
- Subject: Re: Call back to the run loop?
- From: Eric Peyton <email@hidden>
- Date: Sun, 17 Mar 2002 18:06:31 -0600
If all you are doing is a stop button (and nothing else fancy) you could
use the hack I posted to this list about two weeks ago.
In your updateUI() function, run a portion of the main run loop like
this ...
- (void)updateRunLoop
{
id event;
// post events
while (event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode
dequeue:YES]) {
[NSApp sendEvent:event];
}
return;
}
Eric
On Sunday, March 17, 2002, at 02:27 PM, Thomas Lachand-Robert wrote:
Following the discussion with Dietmar Planitzer (see previous
messages), I would like to ask to the list if there is a way to call
back the main run loop of the app. It's a little bit complicated, so
excuse in advance my embarassed english.
The reason I ask is the following (maybe there are better solution than
a call back):
as explained before my app uses a large part of code coming from
another platform, which I don't want to change. It's a computational
thing, meaning the user enters some data, then hit a button "Run"; then
some computations are in progress, then a result is displayed.
The point is that the original app has a button "Stop" and I can't find
a way to implement it. The app stream is as follows:
- the action for "Run" sarts a "compute()" function;
- in the loop of this function, there is a call back "updateUI()" which
I use to update the UI (the number of computed things is displayed);
- but this function compute() doesn't return until computation is
complete or a special global variable "g_computing" is set to false.
So I would like to set this variable to false when the user hit the
"Stop"
button, but this doesn't work since there is no pass in the main run
loop,
so no chance to detect the hit. Hence the question: is it possible to
have a pass through the main run loop (starting from updateUI for
instance)
? Or is there another way to suspend "compute()" for a while, return to
the main run loop, and resume?
I know I could use a multithreaded app, but this would be really very
complicated just to get a "Stop" button.
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.