I detaching The thread as given below to do some operation in background
currentThread = [[NSThread alloc]initWithTarget:contactServiceselector:@selector(requestForContactBackup:)object:msisdn];
[currentThread start];
This currentThread is the pointer of AppDelegate.
I have one button on my view and when i will press it I want to cancel or stop the execution of background thread.
To do This something like this:
-(void)cancelTheRunningTasks {
if(self.currentThread !=nil) {
[currentThread cancel];
NSLog(@"IsCancelled: %d",[currentThread isCancelled]); //here Yes returns
[self removeNetworkIndicatorInView:backUpViewController.view];
}
}
Problem with that the background thread is still under execution.
With my thread refrence how to cancel/stop execution/kill the background thread from main thread ?
please refer some solutions.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…