Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stopping an NSThread (or something similar)




On 14/07/2006, at 11:35 AM, Michael Becker wrote:

Sorry for the forwarding, I used the wrong e-mail account to send this e-mail before...

Anfang der weitergeleiteten E-Mail:
Hi,

my application is designed to upload files via an HTTP POST request. I am using libcurl to do this, as libcurl allows me to monitor the upload progress (which NSURLConnection obviously does not). However, I am having a problem: Naturally, I want the user to be able to click a button to immediately stop the upload. I am uploading the files in a secondary thread. If I use the good ol' technique that's using a BOOL variable to tell the secondary thread to stop, this won't work properly as the thread will only be able to check the variable between file uploads. So if the user triggers a 10 MB upload and wants to stop that, they will have to wait until the 10 MBs are uploaded before the thread stops.

The thing is, that I cannot interfere with the uploading (I guess). I simply call "curl_easy_perform()" and off it goes. The problem I've posted here to me seems to be one of the more fundamental "things-everybody-needs". E.g., Safari allows you to stop the download of files, too. So does more or less any networking application I can think of right now.

How are they doing that?

Regards,
Michael

PS: Remember: I am talking about UPloading files. DOWNloading actually seems to be supported very well and boasting any feature you'd ever wish for...

In Cocoa apps, you shouldn't kill a thread. Read the Multithreading Programming Topics in the docs.


For your particular problem, you need to use the curl_multi API.

Out of interest, why couldn't you use NSURLConnection. I've not tried it, but couldn't you hook into NSInputStream to monitor how much data has been loaded? I'd have thought this might work although only on 10.4.

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Stopping an NSThread (or something similar) (From: Michael Becker <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.