DoApplicationInitialization() public method

Use this for slow operations that should happen during the splash screen instead of during app construction
public DoApplicationInitialization ( IProgress progressDlg ) : void
progressDlg IProgress The progress dialog to use.
return void
Exemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes the specified application and creates a new main window for it. Also
		/// does application-specific cache initialization.
		/// </summary>
		/// <param name="app">The application</param>
		/// <param name="progressDlg">The progress dialog.</param>
		/// <returns>True if the application was started successfully, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		private static bool InitializeApp(FwApp app, IThreadedProgress progressDlg)
		{
			using (new DataUpdateMonitor(null, "Application Initialization"))
				app.DoApplicationInitialization(progressDlg);
			using (new DataUpdateMonitor(null, "Loading Application Settings"))
				app.LoadSettings();

			using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(
				s_cache.ServiceLocator.GetInstance<IActionHandler>()))
			using (new DataUpdateMonitor(null, "Application Cache Initialization"))
			{
				try
				{
					if (!app.InitCacheForApp(progressDlg))
						throw new StartupException(Properties.Resources.kstidCacheInitFailure);
				}
				catch (Exception e)
				{
					if (e is StartupException)
						throw;
					throw new StartupException(Properties.Resources.kstidCacheInitFailure, e, true);
				}
				undoHelper.RollBack = false;
			}

			if (s_cache.ServiceLocator.GetInstance<IUndoStackManager>().HasUnsavedChanges)
			{
				if (progressDlg != null)
				{
					progressDlg.Message = String.Format(Properties.Resources.kstidSaving, s_cache.ProjectId.UiName);
					progressDlg.IsIndeterminate = true;
				}
				s_cache.ServiceLocator.GetInstance<IUndoStackManager>().Save();
				if (progressDlg != null)
					progressDlg.IsIndeterminate = false;
			}

			return CreateAndInitNewMainWindow(app, true, null, false);
		}