I want a method running on a background thread to reissue itself after it is
done processing. How can I do this?
I'm using the following code but it runs just once and is never heard from
again...
// initial invocation from main thread
[self performSelectorInBackground:@selector(_checkSensor:) withObject:@50];
// target method on background thread
-(void)_checkSensor:(NSNumber *)delaySecs
{
// check sensor...
// processing...
// reschedule
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:_cmd
object:nil];
[self performSelector:_cmd withObject:nil afterDelay: delaySecs];
}
As a test, the above works if run on the main thread, so I'm guessing it has
something to do with there being no runloop after the background thread exits.
-Carl
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]