我正在编写一个客观的C程序。下面我列出了一个单击该程序中的按钮后运行的方法。该程序中还有一个停止按钮,当有人点击停止按钮时,我想停止执行此方法并将应用程序的UI恢复到正常运行方法之前的状态。任何人都可以帮我这样做吗?
-(JobStatus)beginUploadingTask{
void (^progressBlock)(void);
progressBlock = ^{
@try{
do {
// calls to some method
dispatch_async(dispatch_get_main_queue(), ^{
//execute some code
});
} while (index<fileSize);
}
@catch (NSException *ex) {
[self taskErrorWithMessage:@"Error in uploading your file. Please try again"];
return;
}
@finally {
NSLog(@ "finally block executed");
}
};
dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
dispatch_async(queue, progressBlock);
return TaskStateUploaded;
}