internal static void GracefullyShutDown()
{
// Give any open main windows a chance to close normally before being forcibly
// disposed.
CloseAllMainWindowsForApp(s_teApp);
CloseAllMainWindowsForApp(s_flexApp);
// Its quite possible that there are some important messages to process.
// (e.g., an FwApp.RemoveWindow asynchronous call from FwMainWnd.Dispose)
// These need to be handled before we shut down the applications or race conditions
// might occur. (FWR-1687)
ExceptionHelper.LogAndIgnoreErrors(Application.DoEvents);
GracefullyShutDownApp(s_teApp);
GracefullyShutDownApp(s_flexApp);
// If FieldWorks was in app server mode, there is a chance that the apps could have
// already been shut down, but the cache is still running. In this case, we need
// to shut down the cache explicitly.
ExitCleanly();
if (!s_noUserInterface)
{
Debug.Assert(s_teApp == null, "The TE app did not get properly cleaned up");
Debug.Assert(s_flexApp == null, "The FLEx app did not get properly cleaned up");
Debug.Assert(s_cache == null, "The cache did not get properly cleaned up");
}
}