protected override void OnLeavePage(LeavePageEventArgs e) { base.OnLeavePage(e); // On Page-Entered event, we spawn another thread that hides DS Wizard (the parent wizard) asynchronously. The problem is that // if the thread runs AFTER this page is closed, the DS wizard will never be visible again. The code below // is added to prevent such problem to surface. _mutex.WaitOne(); // Set the flag to indicate the page is closing. _isPageClosing = true; // Set DS Wizard to be visible if _dismissDSWizard is false; if (_dismissDSWizard == false) { WizardForm.Visible = true; } _mutex.ReleaseMutex(); }