本文整理汇总了C#中Update.Show方法的典型用法代码示例。如果您正苦于以下问题:C# Update.Show方法的具体用法?C# Update.Show怎么用?C# Update.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Update
的用法示例。
在下文中一共展示了Update.Show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SquirrelUpdate
private async Task<string> SquirrelUpdate(bool showInfo)
{
try
{
using (UpdateManager _manager = new UpdateManager(ConfigurationManager.AppSettings["CurrentReleaseURL"]))
{
UpdateInfo _update = await _manager.CheckForUpdate();
if (_update.ReleasesToApply.Any())
{
Version _newVersion = _update.ReleasesToApply.OrderByDescending(r => r.Version).First().Version.Version;
Update _updateWindow = new Update();
_updateWindow.Show();
await _manager.UpdateApp((p) => _updateWindow.SetProgress(p));
_updateWindow.Close();
return Utilities.Paths.Exe(_newVersion);
}
else if (showInfo)
{
MessageBox.Show(Framework.Resources.UpdateSuccessText, Framework.Resources.AppName, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
}
catch (WebException)
{
if (showInfo)
{
MessageBox.Show(Framework.Resources.UpdateErrorText, Framework.Resources.UpdateErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
catch (Exception e)
{
Framework.Settings.Instance.AutoUpdate = false;
Framework.Settings.Instance.Save();
using (EventLog _log = new EventLog("Application"))
{
_log.Source = Framework.Resources.AppName;
_log.WriteEntry(e.ToString(), EventLogEntryType.Error, 100, 1);
}
MessageBox.Show(Framework.Resources.UpdateErrorFatalText, Framework.Resources.UpdateErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
return null;
}
示例2: SquirrelUpdate
private async Task SquirrelUpdate(bool showInfo)
{
try
{
using (UpdateManager _manager = new UpdateManager(ConfigurationManager.AppSettings["CurrentReleaseURL"]))
{
UpdateInfo _update = await _manager.CheckForUpdate();
if (_update.ReleasesToApply.Any())
{
Version _newVersion = _update.ReleasesToApply.OrderByDescending(r => r.Version).First().Version.Version;
Update _updateWindow = new Update();
_updateWindow.Show();
await _manager.UpdateApp((p) => _updateWindow.SetProgress(p));
_updateWindow.Close();
string _newExePath = Utilities.Paths.Exe(_newVersion);
if (Framework.Settings.Instance.RunAtStartup)
{
Utilities.Startup.EnableStartupTask(_newExePath);
}
Process.Start(_newExePath);
Shutdown();
}
else if (showInfo)
{
MessageBox.Show(Constants.Generic.UPDATEMSG, Constants.Generic.PROGRAMNAME, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
}
catch (WebException)
{
if (showInfo)
{
MessageBox.Show(Constants.Generic.UPDATEERROR, Constants.Generic.UPDATEERRORTITLE, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
}