System.Windows.Application.Terminate C# (CSharp) Method

Terminate() private method

private Terminate ( ) : void
return void
		internal void Terminate ()
		{
			if (Deployment.Current.XapDir == null)
				return;

			for (int i = 0; i < ApplicationLifetimeObjects.Count; i++) {
				IApplicationLifetimeAware asvc = ApplicationLifetimeObjects[i] as IApplicationLifetimeAware;
				if (asvc != null)
					asvc.Exiting();
			}
			
			if (Exit != null)
				Exit (this, EventArgs.Empty);

			for (int i = 0; i < ApplicationLifetimeObjects.Count; i++) {
				IApplicationLifetimeAware asvc = ApplicationLifetimeObjects[i] as IApplicationLifetimeAware;
				if (asvc != null)
					asvc.Exited();
			}

			// note: this loop goes in reverse order
			for (int i = ApplicationLifetimeObjects.Count - 1; i >= 0; i--) {
				IApplicationService svc = ApplicationLifetimeObjects[i] as IApplicationService;
				if (svc != null)
					svc.StopService ();
			}
			
			try {
				Directory.Delete (Deployment.Current.XapDir, true);
				Deployment.Current.XapDir = null;
			} catch {
			}

			foreach (KeyValuePair<Assembly, ResourceDictionary> kv in assemblyToGenericXaml)
				kv.Value.Clear ();
			assemblyToGenericXaml.Clear ();
			root_visual = null;
			Application.Current = null;

			ReinitializeStaticData ();
		}