Re: Re[1] Output from NSTask and modal window
Re: Re[1] Output from NSTask and modal window
- Subject: Re: Re[1] Output from NSTask and modal window
- From: "Sven-S. Porst" <email@hidden>
- Date: Thu, 17 Jan 2002 01:09:56 +0100
>
I don't think there is a bug.
>
I think that you are experiencing different mode (i.e
>
priority level) in the NSRunLoop.
Thanks for this hint. I did a bit of reading in the documentation (yet
another topic I didn't want to know about...) and this seems to cause the
problem. Unfortunately switiching to an extra Thread would be quite a lot
of work and cause all kinds of new problems, so I don't want to do it.
(Somehow this seems by far too sophisticated for what I want to do: Ask
the user for some information in a modal window and process something
from this)
For the time being, I have come up with the following which seems to
work: I replaced my call to [NSApp runModalForWindow: myWindow] wiht
modalSession = [NSApp beginModalSessionForWindow:myWindow];
for (;;) {
result = [NSApp runModalSession:modalSession];
if (result != NSRunContinuesResponse)
break;
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate
dateWithTimeIntervalSinceNow:0.1] ];
}
[NSApp endModalSession:modalSession];
thus allowing the app to drop into it's normal run loop where it can get
data the Pipes occasionally. Although this works, I suspect it isn't a
good way to do things as (1) simply calling run instead of runUntil Date
is a very bad idea and freezes everything, so I guess this just freezes
things for a fraction of a second at a time, (2) in this state my app
used about 5% of the processor while doing nothing and (3) there still is
a delay.
So - ist there a way to achieve this more efficiently, i.e.
>
I bveleive that NSPipes coming from NSTasks are only
>
scanned in NSDefaultRunLoopMode.
What about notifications?
My modal window doesn't receive any notifications either. (Unless I use a
menu, which seems to 'purge' all the notifications that got 'stuck').
Again this is resolved by the workaround described above which is
probably bad stylistically and technically.
Sven
--
Sven-S. Porst . PGP: 0x0085ABA3 .
http://homepage.mac.com/ssp
"You can't fight in here, this is the War Room!"
-- Dr. Strangelove