所以我有一个控件,它响应于它的项目被改变,调用UpdateLayout()。这导致堆栈跟踪如下所示:在什么情况下UIElement.UpdateLayout()可以调用Environment.FailFast?
说明:应用程序请求进程通过 终止System.Environment.FailFast(字符串消息)。消息:不可恢复的 系统错误。堆栈:在System.Environment.FailFast(System.String) at MS.Internal.Invariant.FailFast(System.String,System.String)at MS.Internal.Invariant.Assert(Boolean,System.String)at System .Windows.Window.GetWindowMinMax()at System.Windows.Window.MeasureOverride(System.Windows.Size)at System.Windows.FrameworkElement.MeasureCore(System.Windows.Size)at System.Windows.UIElement.Measure( System.Windows.Size)维持在 System.Windows.UIElement.UpdateLayout() System.Windows.ContextLayoutManager.UpdateLayout()在
显然,在某些情况下,GetWindowMinMax()是辉ling某种类型的Assert(),这会导致对Environment.FailFast的调用。在调用UpdateLayout之前可以检查哪些条件以确保不会发生这些情况以避免遇到此错误?
这似乎是真的;然而,你如何解决检查窗口不关闭和在UpdateLayout运行前关闭窗口之间的竞争条件? – GWLlosa
这个调用UpdateLayout的地方在哪里?你能提供更多的堆栈跟踪吗? –