protected Dispose ( bool disposing ) : void | ||
disposing | bool | true if managed resources should be disposed; otherwise, false. |
return | void |
public void ReleaseResources() { if (fm != null && !fm.IsDisposed) { fm.Dispose(); fm = null; } }
static void Main() { //Get the running instance. Process instance = RunningInstance(); if (instance == null) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); //開啟資料庫;// DaoSQL.Instance.OpenDatabase(); while (true) { DialogResult Ret = DialogResult.Cancel; //Login畫面;// Ret = ShowLoginForm(); if (Ret != DialogResult.OK) { break; } //登入成功,顯示主畫面;// FormMain fMain = new FormMain(); fMain.BringToFront(); Ret = fMain.ShowDialog(); //釋放主畫面資源;// fMain.Close(); fMain.Dispose(); //判斷是否為關閉視窗// if (Ret != DialogResult.Retry) { break; } } } else { //There is another instance of this process. HandleRunningInstance(instance); } //強制關閉,避免因thread或是timer尚在啟動,造成程式無法關閉;// Environment.Exit(Environment.ExitCode); }
/// <summary>Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.ApplicationContext" /> and optionally releases the managed resources.</summary> /// <param name="disposing"> /// <see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources. </param> protected override void Dispose(bool disposing) { AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve; ToolPlugInService toolPlugIns = Interlocked.Exchange(ref _toolPlugIns, null); ContentPlugInService contentPlugIns = Interlocked.Exchange(ref _contentPlugIns, null); GraphicsContext context = Interlocked.Exchange(ref _graphicsContext, null); GorgonMefPlugInCache pluginCache = Interlocked.Exchange(ref _pluginCache, null); FormMain mainForm = Interlocked.Exchange(ref _mainForm, null); FormSplash splash = Interlocked.Exchange(ref _splash, null); toolPlugIns?.Dispose(); contentPlugIns?.Dispose(); context?.Dispose(); pluginCache?.Dispose(); mainForm?.Dispose(); splash?.Dispose(); base.Dispose(disposing); }
public void logout() { new FormLogin().Show(); gui.Dispose(); }
static void Main() { //Get the running instance. Process instance = RunningInstance(); if (instance == null) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); Logger.Info("LPS application booting."); //檢查必要的安裝檔;// CheckNecessaryInstaller(); //開啟資料庫;// DaoSQL.Instance.OpenDatabase(); while (true) { //驗證本機序號;// if (FormSnVerify.VerifyMachineSN() == false) { Logger.Info("SN verify failure from program."); break; } DialogResult Ret = DialogResult.Cancel; //Login畫面;// Ret = ShowLoginForm(); if (Ret != DialogResult.OK) { Logger.Info("LPS application is closed from login form."); break; } Logger.Info("LPS login success."); //登入成功,顯示主畫面;// FormMain LpsMain = new FormMain(m_Machine, m_LoginUser); LpsMain.BringToFront(); Ret = LpsMain.ShowDialog(); //Application.Run(LpsMain); //釋放主畫面資源;// LpsMain.Close(); LpsMain.Dispose(); //判斷是否為關閉視窗// if (Ret != DialogResult.Retry) { Logger.Info("LPS application is closed from main form."); break; } Logger.Info("LPS main from logout."); } } else { //There is another instance of this process. HandleRunningInstance(instance); } //啟動備份流程;// BackupProc(); Logger.Info("LPS application close."); //強制關閉,避免因thread或是timer尚在啟動,造成程式無法關閉;// Environment.Exit(Environment.ExitCode); }
/// <summary> /// Initializes a new instance of the <see cref="AppContext"/> class. /// </summary> public AppContext() { float startTime = GorgonTiming.SecondsSinceStart; try { PlugIns.DefaultImageEditorPlugIn = Program.Settings.DefaultImageEditor; _splash = new FormSplash(); MainForm = new FormMain(); _splash.Show(); _splash.Refresh(); // Fade in our splash screen. FadeSplashScreen(true, 500.0f); EditorLogging.Open(); InitializeGraphics(); InitializePlugIns(); InitializeScratchArea(); InitializeInput(); FileManagement.InitializeFileTypes(); // Load the last opened file. if ((Program.Settings.AutoLoadLastFile) && (!string.IsNullOrWhiteSpace(Program.Settings.LastEditorFile))) { LoadLastFile(); } // Set up the default pane. _splash.UpdateVersion(Resources.GOREDIT_TEXT_LOAD_DEFAULT); ContentManagement.DefaultContentType = typeof(DefaultContent); ContentManagement.LoadDefaultContentPane(); // Keep showing the splash screen. while ((GorgonTiming.SecondsSinceStart - startTime) < 3) { Thread.Sleep(1); } FadeSplashScreen(false, 250.0f); // Bring up our application form. MainForm.Show(); } catch (Exception ex) { GorgonDialogs.ErrorBox(null, ex); if ((MainForm != null) && (!MainForm.IsDisposed)) { MainForm.Dispose(); } // Signal quit. Gorgon.Quit(); } finally { if (_splash != null) { _splash.Dispose(); } _splash = null; } }
public static void DestroyFormMain() { FormMain?.Dispose(); FormMain = null; }