我有一个WPF应用程序,它托管了几个WinForms控件。
偶尔,我会上
.NET SystemEvents
抓住一些第一次机会
InvalidAsynchronousStateException
s总是被框架代码捕获(所以我只在Visual Studio的输出窗口中看到它们)。
系统。组件模型。无效异步状态异常
:'调用该方法时出错。目标线程已不存在。'
堆栈跟踪看起来像:
> System.Windows.Forms.dll!System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback, object)
System.dll!Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.Invoke(bool, object[])
System.dll!Microsoft.Win32.SystemEvents.RaiseEvent(bool, object, object[])
System.dll!Microsoft.Win32.SystemEvents.OnUserPreferenceChanging(int, System.IntPtr, System.IntPtr)
System.dll!Microsoft.Win32.SystemEvents.WindowProc(System.IntPtr, int, System.IntPtr, System.IntPtr)
[Native to Managed Transition]
[Managed to Native Transition]
System.dll!Microsoft.Win32.SystemEvents.WindowThreadProc()
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, object, bool)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, object, bool)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, object)
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()
异常总是在应用程序启动和运行时引发的,而不是在启动时——因此主UI线程肯定是可用的。
我需要关心吗?这是a。NET Framework的错误/功能,还是我的应用程序的错误/配置错误?
我很难理解是否出了什么问题。我没有看到对我的应用程序有任何直接影响(没有死锁、没有崩溃、没有GUI故障),但谁知道呢。
Windows 10。NET框架4.7。