internal static MainDialogResult ShowMainDialog(MainDialogResult initial) { using (FormMain Dialog = new FormMain()) { Dialog.Result = initial; new System.Threading.Thread((System.Threading.ThreadStart) delegate { Application.Run(Dialog); }).Start(); Thread.Sleep(100); while (!formCloseTrig) { //Hack here Thread.Sleep(100); } ; MainDialogResult result = Dialog.Result; try { //Dispose of the worker thread when closing the form //If it's still running, it attempts to update a non-existant form and crashes nastily if (Dialog.routeWorkerThread != null) { Dialog.routeWorkerThread.Dispose(); } if (Dialog != null) { Dialog.Dispose(); } } catch (Exception) { }; return(result); } }
internal static MainDialogResult ShowMainDialog(MainDialogResult initial) { formMain Dialog = new formMain(); Dialog.Result = initial; Dialog.ShowDialog(); MainDialogResult result = Dialog.Result; Dialog.Dispose(); return result; }
internal static MainDialogResult ShowMainDialog(MainDialogResult initial) { using (formMain Dialog = new formMain()) { Dialog.Result = initial; Dialog.ShowDialog(); MainDialogResult result = Dialog.Result; //Dispose of the worker thread when closing the form //If it's still running, it attempts to update a non-existant form and crashes nastily Dialog.routeWorkerThread.Dispose(); Dialog.trainWatcher.Dispose(); Dialog.routeWatcher.Dispose(); Dialog.Dispose(); return result; } }