简体   繁体   English

UWP和无头应用程序中未处理的异常

[英]Unhandled exception in UWP and headless apps

I've read a lot about catching unhandled exception in an UWP app. 我已经阅读了很多有关在UWP应用程序中捕获未处理的异常的信息。 All suggest tu use AppDomain.UnhandledException. 所有建议都使用AppDomain.UnhandledException。 But what to do in a headless application, there is no AppDomain and also no UI-thread. 但是在无头的应用程序中要做什么,没有AppDomain,也没有UI线程。

My app starts several threads, binds to several udp/tcp listeners and makes HTTP requests that may crash. 我的应用程序启动了多个线程,绑定到多个udp / tcp侦听器,并发出可能崩溃的HTTP请求。 I want to log theses crashes to stabilize the app. 我想记录这些崩溃以稳定应用程序。

未处理的异常检测封装在Application中 ,该应用程序通常在App.xaml的初始XAML中提供,因此无头应用无法检测到未处理的异常。有一个非常简单的执行模型,并且没有进程边界。如果要在无头应用程序中捕获异常,则应在每个线程中添加try / catch。您可以参考此处以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM