Using NSTimer to call the main thread
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.