NSRunLoop 典型用法
来源:互联网 发布:冷库机组的简易算法 编辑:程序博客网 时间:2024/05/30 04:14
-(void)backgroundThreadStarted {
NSAutoreleasePool* thePool = [[NSAutoreleasePool alloc] init];
// create a scheduled timer
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(backgroundThreadFire:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
m_isBackgroundThreadToTerminate = NO;
// create the runloop
double resolution = 300.0;
BOOL isRunning;
do {
// run the loop!
NSDate* theNextDate = [NSDate dateWithTimeIntervalSinceNow:resolution];
isRunning = [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:theNextDate];
// occasionally re-create the autorelease pool whilst program is running
[thePool release];
thePool = [[NSAutoreleasePool alloc] init];
} while(isRunning==YES && m_isBackgroundThreadToTerminate==NO);
[thePool release];
}
-(void)backgroundThreadFire:(id)sender {
// do repeated work every one second here
// when thread is to terminate, call [self backgroundThreadTerminate];
}
-(void)backgroundThreadTerminate {
m_isBackgroundThreadToTerminate = YES;
CFRunLoopStop([[NSRunLoop currentRunLoop] getCFRunLoop]);
}
- NSRunLoop 典型用法
- NSRunLoop用法
- NSRunloop 的用法
- NSRunloop 的用法
- NSRunloop 的用法
- NSRunLoop的用法
- NSRunLoop
- nsrunloop
- NSRunloop
- nsrunloop
- NSRunLoop
- NSRunloop
- NSRunLoop
- NSRunLoop
- NSRunLoop
- NSRunLoop
- NSRunLoop
- NSRunLoop
- Oracle Grant用法
- 如何学好C++语言
- 使用protobuf定义消息
- windows linux 创建oracle用户及表空间
- HDFS的文件操作流(5)——写操作(NameNode节点)
- NSRunLoop 典型用法
- MySQL与NoSQL——SQL与NoSQL的融合
- JVM的堆栈
- Android如何防止apk程序被反编译
- 较好的两个函数,获取文件扩展名&返回随机文件名
- 【转】各种标点符号和数学符号的英文读法
- linux 环境下c++编程书目推荐
- 初涉OCILIB的使用
- qdot工作记录