代码拉取完成,页面将自动刷新
using WubiMaster.ViewModels;
namespace WubiMaster;
public partial class App : Application
{
private static ViewModelLocator? locator;
private Mutex? mutex;
public static bool IsMaximized { get; set; }
public static ViewModelLocator? Locator => locator ??= App.Current.FindResource("Locator") as ViewModelLocator;
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
try
{
e.Handled = true;
LogHelper.Fatal(e.Exception.Message);
}
catch (Exception ex)
{
LogHelper.Fatal("程序发生致命错误,将终止,请联系开发人员!" + ex.Message);
this.ShowMessage("程序发生致命错误,将终止,请联系开发人员!", DialogType.Error);
Environment.Exit(0);
}
}
private void Application_Exit(object sender, ExitEventArgs e)
{
LogHelper.Info("程序退出");
}
private void Application_Startup(object sender, StartupEventArgs e)
{
if (mutex != null) return;
mutex = new Mutex(true, "WubiMaster", out bool ret);
if (!ret)
{
LogHelper.Info("禁止启用多个进程");
Environment.Exit(0);
return;
}
LogHelper.Info("程序启动");
this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
StringBuilder sbEx = new();
if (e.IsTerminating)
{
sbEx.Append("程序发生致命错误,将终止,请联系开发人员!\n");
}
if (e.ExceptionObject is Exception ex)
{
sbEx.Append(ex.Message);
}
else
{
sbEx.Append(e.ExceptionObject);
}
this.ShowMessage(sbEx.ToString(), DialogType.Error);
}
private void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
{
LogHelper.Fatal(e.Exception.Message);
e.SetObserved();
this.ShowMessage(e.Exception.Message, DialogType.Error);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。