boolean keepTrying = true;
boolean lockResult = false;
// Try to lock up to maxNumberOfRetries times.
// Poll and wait starting with 200 ms.
while(keepTrying) {
lockResult = sess.lockForeground();
if(lockResult) {
keepTrying = false;
break;
}
tryNumber++;