Tuesday, 1 April 2014

Call method after every 1 sec. in Background thread




First time call through:

//call from viewdidload
dispatch_queue_t q_background = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
    dispatch_async(q_background, ^{
        [self checkFileOpenOrNot:nil];
   });




-(void) checkFileOpenOrNot:(id)sender{

//do your code 



dispatch_queue_t q_background = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
            double delayInSeconds = 1.0;
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
            dispatch_after(popTime, q_background, ^(void){
                [self checkFileOpenOrNot:nil];

            });


}

No comments:

Post a Comment