private static void DialogThreadProc() { try { if (keepOpen) { if (dialog == null) { dialogMutex.WaitOne(); dialog = new LoadingDialog(); dialog.StartPosition = FormStartPosition.CenterScreen; dialog.Show(); dialogMutex.ReleaseMutex(); } if (dialog != null) { dialog.UpdateData(); while (keepOpen) { System.Threading.Thread.Sleep(100); Application.DoEvents(); } dialogMutex.WaitOne(); dialog.Close(); dialog.Dispose(); dialog = null; dialogMutex.ReleaseMutex(); } } } catch { } }