• 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: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?


  • Subject: Re: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?
  • From: Camillo Lugaresi <email@hidden>
  • Date: Thu, 16 Feb 2006 01:27:17 +0100

On 15/feb/06, at 19:59, Jim Correia wrote:

I have an application which, upon receiving an apple event in the background starts a timer with

[[NSTimer scheduledTimerWithTimeInterval: 0 target: self selector: @selector(doPostProcessing:) userInfo: nil repeats: NO];

The docs say that passing 0 will cause NSTimer to choose "a nonnegative interval", of unspecified duration. I don't think that's the issue here, especially if everything works when the event is received in the foreground (does it?), but you might want to try passing a small positive value instead of 0.


After executing the script, my timer doesn't fire until the app comes to the foreground, or the mouse pointer moves into one of my apps windows.

As a work-around, you could try using postEvent:atStart: to post a synthesized event of NSPeriodic type; it might be effective in waking up the main thread.



On 16/feb/06, at 01:13, Chuck Soper wrote:

I think that you need to add your timer to the default run loop as follows:

NSTimer *myTimer = [[NSTimer scheduledTimerWithTimeInterval: 0 target: self selector: @selector(doPostProcessing:) userInfo: nil repeats: NO];

[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];

scheduledTimerWithTimeInterval already adds the thread to the current NSRunLoop in the default mode.


Camillo
_______________________________________________
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: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?
      • From: Jim Correia <email@hidden>
References: 
 >NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?
  • Next by Date: Re: Cross-platform?
  • Previous by thread: Re: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?
  • Next by thread: Re: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?
  • Index(es):
    • Date
    • Thread