public static void ShowProcess(string inTitle, string inMessage, Form inParentForm) { // Make sure it is only launched once. if (_processForm != null) { return; } _processForm = new ProcessForm(); _processForm.Text = inTitle; _processForm.Message = inMessage; if (inParentForm != null) { Point centerLoc = new Point(inParentForm.Location.X + (inParentForm.Width - _processForm.Width) / 2, inParentForm.Location.Y + (inParentForm.Height - _processForm.Height) / 2); _processForm.StartPosition = FormStartPosition.Manual; _processForm.Location = centerLoc; } _thread = new Thread(new ThreadStart(ProcessForm.ShowForm)); _thread.IsBackground = true; _thread.SetApartmentState(ApartmentState.STA); _thread.Start(); }
// A static method to close the SplashScreen static public void CloseForm() { if (_processForm != null && _processForm.IsDisposed == false) { // Make it start going away. _thread = null; // we do not need these any more. _processForm.Invoke(new QueueingLib.QueueUCtrl.VoidCallback(_processForm.Close)); _processForm = null; } }