Hi,

We are using a third party library that performs tasks asynchronously. This is ok most of the time, but on some occasions I'd like to be able to wait (not on the main thread) until an operation completes,

The flow basically goes like this:


[theLibraryObject doOperation:myOperation withCompletionBlock:^(void) (ResponseObject* theResponseObject)
                {
//Completion code
                }];

(The Block syntax is wrong I know, but I don't have the source code in front of me.

The "doOperation: withCompletionBlock:" method just queues the operation and returns. When the operation has finished, it calls the completion block.

I'd like to be able to be able to wait in the method that calls doOperation: withCompletionBlock until the completion block is called, something like this:


-(void) doAtomicOperation
{
[self.mLibraryObject doOperation:myOperation withCompletionBlock:^ (void)(ResponseObject* theResponseObject)
                {
//**
//**    Signal thread that started the operation
//**
                SIGNAL
                }];

//**
//**    Wait for Signal before continuing
//**
                WAIT_FOR_SIGNAL

}

Is there a way of doing this and if so I'd be really grateful if someone could show me the code. I've tried using NSLock and NSConditionalLock etc. but can't get it to work!

Thanks a lot
All the Best
Dave




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to