HelmiB
HelmiB

Reputation: 12333

Add operation in queue while requesting ASIHTTPRequest or AFNetworking

I want to add operation into executing request. I read about ASINetworkQueue, but it adds all operation and run it all. but i want to add operation into running queue.

Is this possible? using ASIHTTPRequest or AFNetworking i don't mind, as long as i get what i intend to do.

EDIT

It shows below error while i try to add another request.

[ASINetworkQueue addOperation:]: operation is executing and cannot be enqueued'

Upvotes: 6

Views: 6769

Answers (2)

Daij-Djan
Daij-Djan

Reputation: 50099

You just call addOperation on the request queue. In asi for its ASiNetworkQueue it shouldn't mattter if it is running or not.

Upvotes: 0

iDev
iDev

Reputation: 23278

From the apple documentation for addOperation: it is clear that you cannot add an operation which is executing into a NSOperationQueue.

This is what mentioned there,

An operation object can be in at most one operation queue at a time and this method throws an NSInvalidArgumentException exception if the operation is already in another queue. Similarly, this method throws an NSInvalidArgumentException exception if the operation is currently executing or has already finished executing.

That is the default behavior of NSOperationQueue. You need to make sure that the NSOperation is not executing before adding to queue. There are various properties such as isExecuting, isFinished etc.. to check this.

Upvotes: 11

Related Questions