Fixed up thread handling.
This commit is contained in:
parent
0091ccb447
commit
0e6f0a8576
1 changed files with 10 additions and 3 deletions
|
@ -34,9 +34,15 @@
|
||||||
_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
||||||
|
|
||||||
[request release];
|
[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
|
- (NSDictionary *)properties
|
||||||
|
@ -62,7 +68,6 @@
|
||||||
- (int)read:(void *)buffer amount:(int)amount
|
- (int)read:(void *)buffer amount:(int)amount
|
||||||
{
|
{
|
||||||
while (amount > [_data length] && !_connectionFinished) {
|
while (amount > [_data length] && !_connectionFinished) {
|
||||||
NSLog(@"Waiting: %@", [NSThread currentThread]);
|
|
||||||
[_sem timedWait: 2];
|
[_sem timedWait: 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +101,8 @@
|
||||||
|
|
||||||
- (void)close
|
- (void)close
|
||||||
{
|
{
|
||||||
|
_connectionFinished = YES;
|
||||||
|
|
||||||
[_connection cancel];
|
[_connection cancel];
|
||||||
[_connection release];
|
[_connection release];
|
||||||
_connection = nil;
|
_connection = nil;
|
||||||
|
|
Loading…
Reference in a new issue