Check for null synchronizationcontext
Made dialog cancelable