/// <summary> /// Creates an instance of the results window on a separate thread and invokes an action on that thread. /// </summary> /// <param name="action">The action to be performed.</param> public static ResultsWindow GetResultsWindow(int PID, ResultsWindowInvokeAction action) { ResultsWindow rw = null; string id = string.Empty; if (ResultsWindowsThreaded) { Thread t = new Thread(() => { rw = new ResultsWindow(PID); id = rw.Id; if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) Application.Run(rw); Program.ResultsThreads.Remove(id); }, Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); while (string.IsNullOrEmpty(id)) Thread.Sleep(1); Program.ResultsThreads.Add(id, t); } else { rw = new ResultsWindow(PID); if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) rw.Show(); } return rw; }
public static ResultsWindow GetResultsWindow(int PID, ResultsWindowInvokeAction action) { ResultsWindow rw = null; string id = ""; if (ResultsWindowsThreaded) { Thread t = new Thread(new ThreadStart(delegate { rw = new ResultsWindow(PID); id = rw.Id; if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) Application.Run(rw); Program.ResultsThreads.Remove(id); })); t.SetApartmentState(ApartmentState.STA); t.Start(); while (id == "") Thread.Sleep(1); Program.ResultsThreads.Add(id, t); } else { rw = new ResultsWindow(PID); if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) rw.Show(); } return rw; }