The BAutolock class provides an easy mechanism for automatically locking and unlocking a BLocker object or, more typically, a BLooper. All you need to do is allocate a BAutolock object on the stack and pass it a target BLocker or BLooper. You may want to make sure the lock is in place before proceeding:

BAutolock autolocker(myWindow);
if ( autolocker.IsLocked() ) {
   . . .

When the stack frame is destroyed, the BAutolock object unlocks the target object and then is itself destroyed.

Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.