Recurrent background thread
Recurrent background thread
- Subject: Recurrent background thread
- From: Carl Hoefs <email@hidden>
- Date: Fri, 13 May 2016 12:34:47 -0700
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@hidden)
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:
This email sent to email@hidden