How do I get the UI thread's Dispatcher?

前端 未结 2 556
南笙
南笙 2020-12-03 02:48

Is there any way to get the UI thread\'s Dispatcher when you have no reference to any UI elements?

2条回答
  •  遥遥无期
    2020-12-03 03:00

    You can grab the UI Dispatcher from the static application instance: Application.Current.Dispatcher

    You may want to check Application.Current for null first, as it can be cleared during a shutdown sequence.

提交回复
热议问题