SIL.FieldWorks.Common.Framework.FwApp.Dispose C# (CSharp) Method

Dispose() public method

Must not be virtual.
public Dispose ( ) : void
return void
		public void Dispose()
		{
			Dispose(true);
			// This object will be cleaned up by the Dispose method.
			// Therefore, you should call GC.SupressFinalize to
			// take this object off the finalization queue
			// and prevent finalization code for this object
			// from executing a second time.
			GC.SuppressFinalize(this);
		}

Same methods

FwApp::Dispose ( bool disposing ) : void

Usage Example

Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Shutdowns the specified application. The application will be disposed of immediately.
		/// If no other applications are running, then FieldWorks will also be shutdown.
		/// </summary>
		/// <param name="app">The application to shut down.</param>
		/// <param name="fSaveSettings">True to have the application save its settings,
		/// false otherwise</param>
		/// ------------------------------------------------------------------------------------
		internal static void ShutdownApp(FwApp app, bool fSaveSettings)
		{
			if (app != s_teApp && app != s_flexApp)
				throw new ArgumentException("Application must belong to this FieldWorks", "app");

			if (fSaveSettings)
				app.SaveSettings();

			if (s_activeMainWnd != null && app.MainWindows.Contains(s_activeMainWnd))
			{
				// The application that owns the active main window is being disposed. This
				// means that the window is, most likely, already disposed.
				s_activeMainWnd = null;
			}

			RecordLastAppForProject();

			if (app == s_teApp)
				s_teApp = null;
			else if (app == s_flexApp)
				s_flexApp = null;

			// Make sure we do this after we set the variables to null to keep a race condition
			// from happening where we want to GetOrCreateApplication() for the app that is
			// being disposed.
			try
			{
				app.Dispose();
			}
			catch
			{
				// continue shutdown even with an exception. It's possible we're shutting down because
				// of a crash and we don't know what state the application is in.
			}

			ExitIfNoAppsRunning();
		}