Is there any way to get the UI thread's Dispatcher
when you have no reference to any UI elements?
当您没有引用任何UI元素时,是否有方法获得UI线程的Dispatcher ?
1 个解决方案
#1
86
You can grab the UI Dispatcher from the static application instance: Application.Current.Dispatcher
您可以从静态应用程序实例application . current. Dispatcher获取UI Dispatcher
You may want to check Application.Current
for null first, as it can be cleared during a shutdown sequence.
您可能需要检查应用程序。首先为null的电流,因为在关机序列中可以清除它。
#1
86
You can grab the UI Dispatcher from the static application instance: Application.Current.Dispatcher
您可以从静态应用程序实例application . current. Dispatcher获取UI Dispatcher
You may want to check Application.Current
for null first, as it can be cleared during a shutdown sequence.
您可能需要检查应用程序。首先为null的电流,因为在关机序列中可以清除它。