Re: [RESOLVED] process events in tight loop?
Re: [RESOLVED] process events in tight loop?
- Subject: Re: [RESOLVED] process events in tight loop?
- From: Chase <email@hidden>
- Date: Thu, 14 Jul 2005 01:06:41 -0500
On Jul 13, 2005, at 6:09 PM, Dave Camp wrote:
What's the Cocoa equivalent of REALbasic's App.DoEvents() for
allowing queued events to be processed while busy in a tight loop?
The proper way to handle that would be to not have a long running
tight loop in the main thread. Perform that processing in a
separate thread and maybe use
performSelectorOnMainThread:withObject:waitUntilDone to have the
secondary thread update your progress UI.
I should have been more clear. It's already in a second NSThread and
it is not holding up the gui. It just bothers me having it spinning
there like that without any sort of control of its percentage of
processing time compared to that of the main thread.
To remedy this, I have since set the thread priority at the top of
the thread (before entering the loop) to 0.0, and inside the loop at
the bottom I call [NSThread sleepUntilDate:[NSDate
dateWithTimeIntervalSinceNow:0.1]];
I just want it to come up for air every once in a while and also
allow the main thread a bigger piece of the processing pie.
This should work great (and it appears, so far, that the second
thread still has more than enough oomph to do its thing).
Thanks.
- Chase
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden