【发布时间】:2011-01-08 17:23:04
【问题描述】:
我有 windows.forms 应用程序,它在按钮单击事件处理程序上创建 WPF 窗口。它在 WPF 窗口实例上调用“显示”方法。
当父 windows.forms 窗口位置改变时,WPF 窗口开始监听父窗口事件并尝试调整自身大小(设置 left、top、width、height 属性)(WPF 窗口视觉上跟随 Windows.Forms 窗口,因为它被固定)。
一切正常,但出于某种原因,我偶尔会收到SEH exception was unhandled 弹出窗口:
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm) ...
它不时出现,很难找出我做错了什么。
我还注意到,WPF 窗口和 Windows.Forms 窗口在不同的线程上运行。
有什么想法吗?
【问题讨论】:
标签: wpf thread-safety