• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [RESOLVED] process events in tight loop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: [RESOLVED] process events in tight loop?
      • From: Bill Bumgarner <email@hidden>
References: 
 >process events in tight loop? (From: Chase <email@hidden>)
 >Re: process events in tight loop? (From: Dave Camp <email@hidden>)

  • Prev by Date: Re: Trying to bind to NSTreeController
  • Next by Date: Re: [RESOLVED] process events in tight loop?
  • Previous by thread: Re: process events in tight loop?
  • Next by thread: Re: [RESOLVED] process events in tight loop?
  • Index(es):
    • Date
    • Thread