WPF1
- Addresses an issue where invoking a synchronization Wait on the UI thread can lead to a render-thread failure, due to unexpected re-entrancy.
帮别人用WPF写的一个工具排错,注意到是在某次windows更新后才报的错,看了一下windows的更新内容,发现KB5015730有一项更新内容涉及WPF,故猜测与此有关。
错误涉及的程序逻辑大致描述如下:
1.splash window
public partial class Splash : Window
{
private static Splash splash = null;
private Splash()
{
InitializeComponent();
}
public static void BeginDisplay()
{
if (splash == null)
{
splash = new Splash();
}
splash.Show();
}
public static void EndDisplay()
{
if (splash != null)
{
splash.Close();
splash = null;
}
}
public static void Loading(string text)
{
if (splash == null)
{
return;
}
splash.lblTip.Content = text;
refresh(splash.lblTip);
}
/// <summary>
/// a trick method to refresh a visual element immediately
/// </summary>
/// <param name="d"></param>
private static void refresh(DependencyObject d)
{
d.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Render, new Action(delegate { }));
}
}
2.MainWindow
<Window x:Class="te