Added busy wait function to getInstance so that it always returns an ins...

...tance in the running state or terminates on other invalid instance codes.