endRunLoop = NO;
[NSThread detachNewThreadSelector: @selector(aThreadRoutine:) toTarget:[MyClass class] withObject:nil];
double resolution = 1.0;
BOOL isRunning;
endRunLoop = NO;
do {
NSDate* next = [NSDate dateWithTimeIntervalSinceNow:resolution];
isRunning = [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:next];
} while (isRunning && !endRunLoop);
+ (void) aThreadRoutine:(id)anObject
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// blocking operation here
endRunLoop = YES;
[pool release];
[NSThread exit];
}
別に正しい方法があったらごめん。
0 件のコメント:
コメントを投稿