示例#1
0
        static void Main()
        {
            using (Mutex mutex = new Mutex(false, "Global\\" + appGuid)) {
                if (!mutex.WaitOne(0, false))
                {
                    MessageBox.Show("Application is already running.", "Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                LoadingScreenForm.ShowLoadingScreen();
                LoadingScreenForm.CloseForm();

                LoginForm frmLogin = new LoginForm();
                MainForm  frmMain  = new MainForm();

                frmLogin.MainForm = frmMain;

                if (frmLogin.ShowDialog() == DialogResult.OK)
                {
                    Application.Run(frmMain);
                }
                else
                {
                    Application.Exit();
                }
            }
        }
 static private void CloseFormInternal()
 {
     if (frmLoadingScreen != null)
     {
         frmLoadingScreen.Close();
         frmLoadingScreen = null;
     }
     ;
 }
        static public void ShowLoadingScreen()
        {
            if (frmLoadingScreen != null)
            {
                return;
            }
            frmLoadingScreen = new LoadingScreenForm();
            Thread thread = new Thread(new ThreadStart(LoadingScreenForm.ShowForm));

            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }