在 App.xaml.cs 中重置光标,在调度程序未处理异常上

本文关键字:调度程序 未处理 异常 App xaml cs 置光标 | 更新日期: 2023-09-27 18:32:29

调度程序未处理异常事件发生时,是否可以(如果是,怎么可能)重置 App.xaml 中的光标.cs。

在意外发生后进行清理。

在 App.xaml.cs 中重置光标,在调度程序未处理异常上

假设你的意思是鼠标光标,并且你想防止应用程序崩溃:

App.xaml

<Application x:Class="WpfApplication1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml" 
             DispatcherUnhandledException="Application_DispatcherUnhandledException">
  <Application.Resources>
  </Application.Resources>
</Application>

应用xaml.cs

private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
  // resets the cursor
  Mouse.OverrideCursor = null;
  // prevents the app from crashing
  e.Handled = true;
}