I want to fire off a method and have it run in the background - I do not care what really happens to it after it is started.
So in my main viewDidLoadMethod I have all o
I went the long way around but finally got the concept in my head and here is what is working perfectly for me:
dispatch_queue_t newImages = dispatch_queue_create("com.mydomain.app.newimagesinbackground", NULL); // create my serial queue
dispatch_async(newImages, ^{
[self getNewImages]; // call my function - this get added first in my serial queue
});
dispatch_async(newImages, ^{
dispatch_async(dispatch_get_main_queue(), ^{
// add this to the main queue as the last item in my serial queue
// when I get to this point I know everything in my queue has been run
dispatch_release(newImages);
});
});
My main problem was using the ASIHTTPRequest startAsynchronous method: http://allseeing-i.com/ASIHTTPRequest/How-to-use#using_blocks
That in essence was creating my bottleneck, 2000 images to get, 2000 asynchronous calls trying to be made. If I am already in the background the startSynchronous method works just fine and only 1 call is trying to run at a time.