try {
if (shouldTrace) {
client2 = this.getClient().withRequestFilterLast(new ClientRequestTrackingHandler(invocationId)).withResponseFilterLast(new ClientRequestTrackingHandler(invocationId));
}
OperationResponse response = client2.getVirtualMachinesOperations().beginCapturingOSImageAsync(serviceName, deploymentName, virtualMachineName, parameters).get();
OperationStatusResponse result = client2.getOperationStatusAsync(response.getRequestId()).get();
int delayInSeconds = 30;
if (client2.getLongRunningOperationInitialTimeout() >= 0) {
delayInSeconds = client2.getLongRunningOperationInitialTimeout();
}
while ((result.getStatus() != OperationStatus.InProgress) == false) {
Thread.sleep(delayInSeconds * 1000);
result = client2.getOperationStatusAsync(response.getRequestId()).get();
delayInSeconds = 30;
if (client2.getLongRunningOperationRetryTimeout() >= 0) {
delayInSeconds = client2.getLongRunningOperationRetryTimeout();
}
}