Exemple #1
0
        void SaveAsync(SaveModuleOptionsVM[] mods)
        {
            try {
                moduleSaver = new ModuleSaver(mods);
                moduleSaver.OnProgressUpdated += moduleSaver_OnProgressUpdated;
                moduleSaver.OnLogMessage      += moduleSaver_OnLogMessage;
                moduleSaver.OnWritingFile     += moduleSaver_OnWritingFile;
                moduleSaver.SaveAll();
                AsyncAddMessage("All files written to disk.", false, false);
            }
            catch (TaskCanceledException) {
                AsyncAddMessage("Save was canceled by user.", true, false);
            }
            catch (UnauthorizedAccessException ex) {
                AsyncAddMessage(string.Format("Access error: {0}", ex.Message), true, false);
            }
            catch (IOException ex) {
                AsyncAddMessage(string.Format("File error: {0}", ex.Message), true, false);
            }
            catch (Exception ex) {
                AsyncAddMessage(string.Format("An exception occurred\n\n{0}", ex), true, false);
            }
            moduleSaver = null;

            ExecInOldThread(() => {
                CurrentFileName = string.Empty;
                State           = SaveState.Saved;
            });
        }
Exemple #2
0
        void SaveAsync(SaveModuleOptionsVM[] mods)
        {
            try {
                moduleSaver = new ModuleSaver(mods);
                moduleSaver.OnProgressUpdated += moduleSaver_OnProgressUpdated;
                moduleSaver.OnLogMessage += moduleSaver_OnLogMessage;
                moduleSaver.OnWritingFile += moduleSaver_OnWritingFile;
                moduleSaver.SaveAll();
                AsyncAddMessage("All files written to disk.", false, false);
            }
            catch (TaskCanceledException) {
                AsyncAddMessage("Save was canceled by user.", true, false);
            }
            catch (UnauthorizedAccessException ex) {
                AsyncAddMessage(string.Format("Access error: {0}", ex.Message), true, false);
            }
            catch (IOException ex) {
                AsyncAddMessage(string.Format("File error: {0}", ex.Message), true, false);
            }
            catch (Exception ex) {
                AsyncAddMessage(string.Format("An exception occurred\n\n{0}", ex), true, false);
            }
            moduleSaver = null;

            ExecInOldThread(() => {
                CurrentFileName = string.Empty;
                State = SaveState.Saved;
            });
        }