コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: yousafgill/RazorPad
        private void OnAutoSave(object sender, EventArgs e)
        {
            if (AutoSaver == null)
            {
                return;
            }

            var template = sender as RazorTemplateViewModel ?? CurrentTemplate;

            if (template == null)
            {
                return;
            }

            new TaskFactory().StartNew(() => {
                try
                {
                    AutoSaver.Save(template.Document);
                    Log.Info("Auto-Saved the document for you -- you can thank me later.");
                }
                catch (Exception ex)
                {
                    Log.WarnException("Auto-save failed", ex);
                }
            });
        }
コード例 #2
0
 private async void AutoSaveTimerElapsed(object sender, ElapsedEventArgs e)
 {
     try
     {
         await AutoSaver.Save(Tabs);
     }
     catch (Exception ex)
     {
         // we just catch and log any errors, we don't want the autosave timer to be
         // the cause of any crashes itself
         Log.Error(ex, "{class} {method} {message}", "ShellViewModel", "AutoSaveTimerElapsed", ex.Message);
     }
 }
コード例 #3
0
ファイル: ShellViewModel.cs プロジェクト: shichiyou/DaxStudio
        private async void AutoSaveTimerElapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                // disable the timer while we are saving, so that if access to the UI thread is
                // blocked and we cannot read the contents of the editor controls we do not keep
                // firing access denied errors on the autosave file. Once the UI thread is free
                // the initial request will continue and the timer will be re-enabled.

                AutoSaveTimer.Enabled = false;

                await AutoSaver.Save(Tabs).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                // we just catch and log any errors, we don't want the autosave timer to be
                // the cause of any crashes itself
                Log.Error(ex, "{class} {method} {message}", "ShellViewModel", "AutoSaveTimerElapsed", ex.Message);
            }
            finally
            {
                AutoSaveTimer.Enabled = true;
            }
        }
コード例 #4
0
ファイル: ShellViewModel.cs プロジェクト: shichiyou/DaxStudio
 public void Handle(AutoSaveEvent message)
 {
     AutoSaver.Save(Tabs).AsResult();
 }