You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.1 KiB
79 lines
2.1 KiB
using JiLinApp.Core;
|
|
using JiLinApp.Pages.Main;
|
|
using NewLife.Log;
|
|
using Prism.Ioc;
|
|
using Prism.Modularity;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Threading;
|
|
|
|
namespace JiLinApp;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App
|
|
{
|
|
public App() : base()
|
|
{
|
|
RegisterEvents();
|
|
Global.Init();
|
|
}
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
protected override Window CreateShell()
|
|
{
|
|
return Container.Resolve<MainWindow>();
|
|
}
|
|
|
|
protected override void RegisterTypes(IContainerRegistry containerRegistry)
|
|
{
|
|
//containerRegistry.RegisterSingleton<IMessageService, MessageService>();
|
|
}
|
|
|
|
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
|
|
{
|
|
//moduleCatalog.AddModule<ModuleNameModule>();
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
base.OnInitialized();
|
|
}
|
|
|
|
#region Bind
|
|
|
|
private void RegisterEvents()
|
|
{
|
|
//UI线程未捕获异常处理事件(UI主线程)
|
|
DispatcherUnhandledException += App_DispatcherUnhandledException;
|
|
|
|
//Task线程内未捕获异常处理事件
|
|
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
|
|
|
|
//非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
}
|
|
|
|
private static void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
|
{
|
|
XTrace.Log.Error("{0}", e.Exception.Message);
|
|
}
|
|
|
|
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
|
|
{
|
|
XTrace.Log.Error("{0}", e.Exception.Message);
|
|
}
|
|
|
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
{
|
|
XTrace.Log.Error("{0}", ((Exception)e.ExceptionObject).Message);
|
|
}
|
|
|
|
#endregion Bind
|
|
}
|