RestartBloom() public static method

public static RestartBloom ( ) : void
return void
Example #1
0
        protected override void OnClosing(CancelEventArgs e)
        {
            //get everything saved (under the old collection name, if we are changing the name and restarting)
            _libraryClosingEvent.Raise(null);

            if (!string.IsNullOrEmpty(_nameToChangeCollectionUponClosing) &&
                _nameToChangeCollectionUponClosing != _collectionSettings.CollectionName &&
                UserWantsToOpeReopenProject)
            {
                // Without checking and resetting this flag, Linux endlessly spawns new instances. Apparently the Mono runtime
                // calls OnClosing again as a result of calling Program.RestartBloom() which calls Application.Exit().
                UserWantsToOpeReopenProject = false;
                //Actually restart Bloom with a parameter requesting this name change. It's way more likely to succeed
                //when this run isn't holding onto anything.
                try
                {
                    var existingDirectoryPath = Path.GetDirectoryName(_collectionSettings.SettingsFilePath);
                    var parentDirectory       = Path.GetDirectoryName(existingDirectoryPath);
                    var newDirectoryPath      = Path.Combine(parentDirectory, _nameToChangeCollectionUponClosing);

                    Program.RestartBloom(string.Format("--rename \"{0}\" \"{1}\" ", existingDirectoryPath, newDirectoryPath));
                }
                catch (Exception error)
                {
                    SIL.Reporting.ErrorReport.NotifyUserOfProblem(error,
                                                                  "Sorry, Bloom failed to even prepare for the rename of the project to '{0}'", _nameToChangeCollectionUponClosing);
                }
            }

            base.OnClosing(e);
        }