Re: Synchronous method: How to "wait" for Notification to occur?
Re: Synchronous method: How to "wait" for Notification to occur?
- Subject: Re: Synchronous method: How to "wait" for Notification to occur?
- From: Andreas Mayer <email@hidden>
- Date: Fri, 22 Aug 2003 00:53:11 +0200
Am Donnerstag, 21.08.03 um 21:26 Uhr schrieb Rolf:
What's the most elegant way for the method to "wait" for the
Notification ? The main RunLoop must be kept active, and the "wait"
must not hog CPU time by continually checking if the Notification has
arrived. Any good ideas ?
Well, I'm not sure if it's the most elegant solution, but it seems to
fit your requirements:
- start a second thread for your synchronous method: [NSThread
detachNewThreadSelector:@selector(<yourSynchronousMethod>)
toTarget:<yourTarget> withObject:<someParameter>]
- inside that method set a lock with [lock lockBeforeDate:[NSDate
dateWithTimeIntervalSinceNow:1.0]] (will wait at most 1 second for the
lock to get removed)
- register some object to receive the notification and [lock unlock]
the above lock when it's called
bye. Andreas.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.