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,但執行處理常式的原因是系統程式碼 (不是應用程式程式碼) 引發事件。 應用程式程式碼不一定會看到該錯誤或看到處理程式已執行。

從任何委派傳回失敗會清除錯誤的已處理狀態。

適用於