NSOperation *operation = /*some operation*/;
[operationQueue addOperation:operation];
// …
// Some work
// …
return Value;
I want to get Value from function before operation ends.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As far as I know, you can’t.
You may wait for an operation to be done, but trying to preempt a threadpool task is somewhat pointless.
Even if you managed to pause/suspend the queue before you add your
operation, you still have to resume it before youreturn, and you have no way to avoid a possible context switch at this point.If the
Valuebeing returned is a shared var/global/field which might get modified by the operation, you may copy/clone its current value into a tempvar/local before theaddOperationto return it later.