• 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
Using NSTimer to call the main thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSTimer to call the main thread


  • Subject: Using NSTimer to call the main thread
  • From: Peter Robinson <email@hidden>
  • Date: Thu, 27 Mar 2003 18:12:14 +0000

I am trying to communicate with the main thread in order to update the user interface.

From my secondary thread, I can install a one-off NSTimer on the run-loop of the main thread, like this:

NSTimer *timer = [NSTimer timerWithTimeInterval: 0
target: self selector: @selector(updateValueNow:)
userInfo: nil repeats: NO];

[mainRunLoop addTimer: timer forMode: NSDefaultRunLoopMode];

which seems to work well enough. But I am worried that it isn't legal to install a timer on a run-loop from another thread. Can I do this? If not, what is the simplest way to get code called on the main thread? I am using 10.1.

Thanks,

Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Using NSTimer to call the main thread
      • From: John Anderson <email@hidden>
  • Prev by Date: Re: Japanese name for FileMaker
  • Next by Date: Re: Need advice: handling SQL DB based datasource for NSTableView
  • Previous by thread: Re: Japanese name for FileMaker
  • Next by thread: Re: Using NSTimer to call the main thread
  • Index(es):
    • Date
    • Thread