This is what my code looks like now and I want to call these methods in a serial manner:
-(void) methodOnBackThread // this method will run on a background thread
{
[runner runThisMethod]; // and this will run on the same background thread as well
[runner runThisOtherMethod]; // and so will this one
// but I want this one to run on the main thread :
[runner runThisMethodOnTheMainThreadUsing:thisParameter using:thisOtherParamater andUsing:thisOtherOneAsWell];
[runner runThisOtherMethod]; // this one will run on the background thread as well
// but I want this one to run on the main thread :
[runner runThisMethodOnTheMainThreadUsing:thisParameter using:thisOtherParamater andUsing:thisOtherOneAsWell];
[runner runThisOtherMethod]; // this one will run on the background thread as well
// etc..
}
I believe I have to use dispatch_get_main_queue but I can’t figure out how to implement this in the above case.
How do I submit [runner runThisMethodOnTheMainThreadUsing:thisParameter using:thisOtherParamater andUsing:thisOtherOneAsWell]; to the Main Thread, then return to the execution of the rest of my background methods and then get the main thread again if the next method in line needs it?
If you are targeting iOS4 and aboveUse grand central dispatch. You can do something like this: