• 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: Chuck Soper <email@hidden>
  • Date: Wed, 15 Feb 2006 16:13:31 -0800

At 1:59 PM -0500 2/15/06, 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];

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.

I've changed that code to use -performSelector:withObject:afterDelay: to no avail (it has the same properties.)

Is this expected?

What is the proper way to run a delayed action in this scenario?

Thanks,
Jim

Jim,

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];

If that doesn't work, let me know. My application fires NSTimer objects in the background fine, yet I don't initialize the timer in the background.

Chuck
_______________________________________________
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


References: 
 >NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: Strange file system behavior
  • Next by Date: Re: NSTimer and -[NSObject performSelector:withObject:afterDelay:] in the background?
  • Previous by thread: 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