Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSOperationQueue with a timer

I would like to use an NSOperationQueue which has got a timer inside it. For example - I download 1 element (complete the 1st NSOperation) then I want to wait for 3 seconds before the compiler goes on to the next operation. After the 2nd NSOperation has been completed I want it to wait for the same 3 seconds and then start the operation number 3.

How can this behaviour be implemented? I have no prior experience of using NSTimer or NSRunLoop and I'm unsure whether I should use them at all.

Thanks in advance.

like image 801
Sergey Grischyov Avatar asked Apr 14 '26 18:04

Sergey Grischyov


1 Answers

As long as the operations are executed in background thread;

You can set the maxConcurrentOperationCount to 1 and use the sleep(3) for 3 seconds in your operation block.

like image 87
Mert Avatar answered Apr 16 '26 10:04

Mert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!