I'm implementing a download manager in cocoa. The user can add several download requests, and the request manager will show the progress of the requests in a panel. I came into problem about the pause/resume of the request in the queue.
For simplicity, supposing the max concurrent operation count is 1, I add several requests with order:1, 2, 3,4,5. If it is not interrupted, the request is downloaded from 1 to 5 in sequence. Supposing I pause the request 1, the request 2 should continue to download. During that time, I resume the request 1. Hence, after the request 2 is finished, I hope the request 1 can be continued before request 3.
The problem here is that: For the single request when I paused it, the request in fact was cancelled. when I resumed the request, a new request was initialed and then started. In an operation queue, now I sent [self cancel]
if the request was paused so that the next request could be started. However, I don't know how to do if it is resumed. The canceled request cannot be added to the queue again. If I created a new one and add it to the queue, how can I promise the priority like the before?
Please give tips on how to do it.
thanks