Bug fix when a dialog is invoked by another thread