internal class SpashWindowManager { private static SpashWindow _spashWindow; private static Thread thread; public static void Show() { thread = new Thread(() => { _spashWindow = new SpashWindow(); _spashWindow.Show(); try { Dispatcher.Run(); } catch (Exception e) { LogHelper.WriteLog(e.Message, LogType.Error); } }) { IsBackground = true }; thread.SetApartmentState(ApartmentState.STA); thread.Start(); } public static void Close() { Dispatcher.FromThread(thread)?.Invoke(() => { try { _spashWindow.Close(); } catch (Exception e) { LogHelper.WriteLog($" {e.StackTrace.ToString()} {e.Message}", LogType.Error); } }); } }
标签:thread,private,LogType,static,UI,线程,WPF,spashWindow From: https://www.cnblogs.com/Koalin/p/17816760.html