var choice = -1; choice = dialog(); while (choice < 0) { // do this while you wait } // do this once choice is made