RE: NSURLDownload delegate methods seperate thread
RE: NSURLDownload delegate methods seperate thread
- Subject: RE: NSURLDownload delegate methods seperate thread
- From: "Colin Deasy" <email@hidden>
- Date: Wed, 9 Sep 2009 16:35:59 +0100
Ok so I have tried both ways, using the main thread for the download
messages and using NSOperationQueue to create separate threads & run loops.
I'm still getting 30% CPU though. When I run it, my app seems to send the
kernel_task a bit crazy (that's where most of the CPU is going). I created a
bare minimum app with just one NSUrlDownload with a delegate and it still
exhibits the same behaviour.
Just to note, this doesn't happen in 10.5 ( not with NSUrlDownload anyway,
it did happen frequently with NSUrlConnection ).
Anyone shed any light?
-----Original Message-----
From: Dave Carrigan [mailto:email@hidden]
Sent: 08 September 2009 22:12
To: Colin Deasy
Cc: email@hidden; email@hidden
Subject: Re: NSURLDownload delegate methods seperate thread
On Sep 8, 2009, at 1:43 PM, Colin Deasy wrote:
> Spot on, thanks man.
>
> Fixed it using:
> [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]];
> while ([self isDownloading] );
This will work, but you won't be able to know if your NSInvocationQueue
wants to cancel. If that's important, then this would be better:
while ([self isDownloading] && ![self isCancelled]) {
[[NSRunLook currentRunLoop] runUntilDate:[NSDate
dateWithTimeIntervalSinceNow:0.001]];
}
This assumes that your object inherits from NSOperation. You might also want
to cancel the NSURLConnection if the operation gets cancelled.
--
Dave Carrigan
email@hidden
Seattle, WA, USA
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden