remove an ASIHTTPRequest thread when it is done
- by user262325
Hello everyone
I have a project in which it runs 5 download threads
- (void)fetchThisURLFiveTimes:(NSURL *)url
{
[myProgressIndicator setProgress:0];
NSLog(@"Value: %f", [myProgressIndicator progress]);
[myQueue cancelAllOperations];
[myQueue setDownloadProgressDelegate:myProgressIndicator];
[myQueue setDelegate:self];
[myQueue setRequestDidFinishSelector:@selector(queueComplete:)];
int i;
for (i=0; i<5; i++) {
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDelegate:self];
[myQueue addOperation:request];
}
[myQueue go];
}
- (void)requestWentDone:(ASIHTTPRequest *)request
{
//..
}
- (void)queueComplete:(ASINetworkQueue *)queue
{
NSLog(@"Value: %f", [myProgressIndicator progress]);
}
I hope to remove a thread when it is done. I do not know where I need to place my codes:
requestWentDone:(ASIHTTPRequest *)request
or
queueComplete:(ASINetworkQueue *)queue
I noticed there is no tag property for request, so I added it to ASIHTTPRequest to help me recognize which thread prompts the function reuqestWentDone,
I can get the tag of different request, but I do not know how to remove the ASIHTTPRequest thread from myQueue.
Welcome any comment
Thanks
interdev