使用反射从 class 库中获取 app.dispatcher

Use reflection to get app.dispatcher from class library

有没有办法使用反射从 class 库中获取应用程序调度程序?我试过的都没有用。

您可以通过调用 System.Windows.Application.Current.Dispatcher

来获取调度程序

您需要添加对 PresentationFrameworkWindowsBaseSystem.Xaml 的引用才能从普通 class 库访问 Application class。