相关疑难解决方法(0)

由于 SystemEvents.OnUserPreferenceChanged 事件,WinForms 应用程序挂起

我一直在处理一个奇怪的应用程序挂在我的客户端安装中。在尝试了几件事之后,我得出的结论是,如果没有转储,它将无法工作。所以我在挂机时间从我的一个客户那里得到了一个转储。我必须注意,它只发生在我的安装中,而不发生在我的开发计算机中。

在我的转储中,我看到 SystemEvents.OnUserPreferenceChanged 事件导致我的 UI 线程阻塞等待线程,即不再泵送消息。

在这里和谷歌搜索后,我发现有些人也有这个问题。我上下检查我的代码,看看我们是否有机会在非 UI 线程上创建了一个控件或表单,但没有运气。

这是我的 !clrstack

 0012ee5c 7c90e514 [HelperMethodFrame_1OBJ: 0012ee5c] 
System.Threading.WaitHandle.WaitOneNative(Microsoft.Win32.SafeHandles.SafeWaitHandle, UInt32, Boolean, Boolean)
0012ef08 792b68af System.Threading.WaitHandle.WaitOne(Int64, Boolean)
0012ef24 792b6865 System.Threading.WaitHandle.WaitOne(Int32, Boolean)
0012ef38 7b6f1a4f System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle)
0012ef4c 7ba2d68b System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)
0012efec 7b6f33ac System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])
0012f020 7b920bd7 System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback, System.Object)
0012f038 7a92ed62 Microsoft.Win32.SystemEvents+SystemEventInvokeInfo.Invoke(Boolean, System.Object[])
0012f06c 7a92dc8f Microsoft.Win32.SystemEvents.RaiseEvent(Boolean, System.Object, System.Object[])
0012f0b8 7a92e227 Microsoft.Win32.SystemEvents.OnUserPreferenceChanged(Int32, IntPtr, IntPtr)
0012f0d8 7aaa06ec Microsoft.Win32.SystemEvents.WindowProc(IntPtr, Int32, IntPtr, IntPtr)
0012f0dc 003c222c [InlinedCallFrame: 0012f0dc] 
0012f2a0 7b1d8d2e System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)
0012f33c 7b1d8997 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
0012f390 7b1d87e1 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, …
Run Code Online (Sandbox Code Playgroud)

.net c# winforms

3
推荐指数
1
解决办法
5517
查看次数

标签 统计

.net ×1

c# ×1

winforms ×1