CoreApplication.UnhandledErrorDetected 事件

定义

当作为全局错误处理逻辑的一部分路由到 CoreApplication 实例的基础错误时发生。

// Register
static event_token UnhandledErrorDetected(EventHandler<UnhandledErrorDetectedEventArgs> const& handler) const;

// Revoke with event_token
static void UnhandledErrorDetected(event_token const* cookie) const;

// Revoke with event_revoker
static CoreApplication::UnhandledErrorDetected_revoker UnhandledErrorDetected(auto_revoke_t, EventHandler<UnhandledErrorDetectedEventArgs> const& handler) const;
public static event System.EventHandler<UnhandledErrorDetectedEventArgs> UnhandledErrorDetected;
function onUnhandledErrorDetected(eventArgs) { /* Your code */ }
Windows.ApplicationModel.Core.CoreApplication.addEventListener("unhandlederrordetected", onUnhandledErrorDetected);
Windows.ApplicationModel.Core.CoreApplication.removeEventListener("unhandlederrordetected", onUnhandledErrorDetected);
- or -
Windows.ApplicationModel.Core.CoreApplication.onunhandlederrordetected = onUnhandledErrorDetected;
Public Shared Custom Event UnhandledErrorDetected As EventHandler(Of UnhandledErrorDetectedEventArgs) 

事件类型

注解

作为应用的生命周期管理代码的一部分,开发人员可以从 UnhandledErrorDetected 事件检查错误数据 (UnhandledError) ,并选择是否将错误标记为已处理。 如果在事件数据中将错误标记为已处理,则可以继续执行。 如果未将错误标记为已处理,则应用及其进程将终止。

可以触发 UnhandledErrorDetected 的错误 包括由异步完成处理程序中的代码引发的错误。

如果应用代码事件处理程序引发错误,则会发生 UnhandledErrorDetected,但执行处理程序的原因是系统代码 (而不是应用代码) 引发该事件。 应用代码并不总是看到该错误或处理程序已执行。

从任何委托返回失败将清除错误的已处理状态。

适用于