NSTimer NSThread
【摘要】
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(UpdateTimerFunc:) userInfo:nil repeats:YES]; -(void)UpdateTi...
-
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(UpdateTimerFunc:) userInfo:nil repeats:YES];
-
-
-
-
-(void)UpdateTimerFunc:(NSTimer *)theTimer
-
{
-
-
[updateGpsTimer invalidate];//stop timer
-
return;
-
}
-
NSThread *InitThread = [[NSThread alloc]initWithTarget:self selector:@selector(InitThreadFunc:) object:self];
-
[InitThread start];
-
-(void)InitThreadFunc:(id)sender
-
{
-
ViewController *fSelf = (ViewController*)sender;
-
[g_soapReadUserMsgFromSql];
-
-
[selfloadWeather];
-
-
}
[self performSelectorOnMainThread:@selector(DuquDBQiye:) withObject:nil waitUntilDone:NO];
GCD实现异步
-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
// 耗时的操作
-
dispatch_async(dispatch_get_main_queue(), ^{
-
// 更新界面
-
});
-
});
-
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
dispatch_group_t group = dispatch_group_create();
-
dispatch_group_async(group, queue, ^{
-
[NSThread sleepForTimeInterval:1];
-
NSLog(@"group1");
-
});
-
dispatch_group_async(group, queue, ^{
-
[NSThread sleepForTimeInterval:2];
-
NSLog(@"group2");
-
});
-
dispatch_group_async(group, queue, ^{
-
[NSThread sleepForTimeInterval:3];
-
NSLog(@"group3");
-
});
-
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
-
NSLog(@"updateUi");
-
});
-
dispatch_release(group);
文章来源: zzzili.blog.csdn.net,作者:清雨小竹,版权归原作者所有,如需转载,请联系作者。
原文链接:zzzili.blog.csdn.net/article/details/8278290
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者

评论(0)