Fixed up thread handling.

CQTexperiment
vspader 2007-10-14 16:37:06 +00:00
parent 0091ccb447
commit 0e6f0a8576
1 changed files with 10 additions and 3 deletions

View File

@ -34,9 +34,15 @@
_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[request release];
NSDate* endDate = [NSDate distantFuture];
do
{
NSLog(@"IN THREAD");
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate];
} while (!_connectionFinished);
[[NSRunLoop currentRunLoop] run];
NSLog(@"Exiting thread");
}
- (NSDictionary *)properties
@ -62,7 +68,6 @@
- (int)read:(void *)buffer amount:(int)amount
{
while (amount > [_data length] && !_connectionFinished) {
NSLog(@"Waiting: %@", [NSThread currentThread]);
[_sem timedWait: 2];
}
@ -96,6 +101,8 @@
- (void)close
{
_connectionFinished = YES;
[_connection cancel];
[_connection release];
_connection = nil;