我有线程异常处理程序,它保存异常堆栈跟踪并应该关闭应用程序。我调用 Applicatoin.Exit,但这只会关闭窗口,让应用程序无窗口运行。
我知道,这通常是因为一些后台线程仍在运行。我将windbg附加到无窗口进程,似乎只有两个托管线程,其中一个看起来像gc终结器线程,第二个看起来像消息泵???有人明白这个吗?
调用 Application.Exit 和用户关闭主窗口之间有区别吗?
0:005> !线程
线程数:2
未启动线程:0
背景线程:1
待处理线程:0
死线:0
托管运行时:否
PreEmptive GC 分配锁
ID OSID ThreadOBJ State GC Context Domain Count APT Exception
0 1 284 002e9668 6020 启用 021a7268:021a7fe8 002e4c68 0 STA
2 2 d48 002f9890 b220 启用 00000000:00000000 002e4c68 0 MTA(终结器)
0:001> ~0 秒
*** 错误:找不到符号文件。默认为 C:\Windows\system32\MSCTF.dll 导出符号 -
eax=02162530 ebx=002e9668 ecx=02162530 edx=02162530 esi=0019ef9c edi=0019ee3c
eip=77589a94 esp=0019edcc ebp=0019ede8 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
ntdll!KiFastSystemCallRet:
77589a94 c3 雷特
0:000> !clrstack
操作系统线程 ID:0x284 (0)
ESP EIP
0019ef24 77589a94 [ComPlusMethodFrameGeneric: 0019ef24] MS.Win32.UnsafeNativeMethods+ITfMessagePump.GetMessageW(System.Windows.Interop.MSG ByRef, Int32, Int32, Int32, Boolean ByRef)
0019ef44 56d61937 System.Windows.Threading.Dispatcher.GetMessage(System.Windows.Interop.MSG ByRef,IntPtr,Int32,Int32)
0019ef90 56d617e3 System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
0019efe0 56d616c7 System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
0019effc 56d6162d System.Windows.Threading.Dispatcher.Run()
0019f008 5533ddb0 System.Windows.Application.RunInternal(System.Windows.Window)
0019f034 5533dbe5 System.Windows.Application.Run(System.Windows.Window)
0019f044 5533d836 System.Windows.Application.Run()
0019f04c 01ea00ad UI.App.Main()
0019f268 79e7c74b [GCFrame: 0019f268]