你的位置: 码友网首页 / 资讯源列表 / WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null

关于[WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null]的摘要:

更新于 2019-08-27 05:05在 WPF 程序中,可能会存在 Application.Current.Dispatcher.Xxx 这样的代码让一部分逻辑回到主 UI 线程。因为发现在调用这句代码的时候出现了 NullReferenceException,于是就有三位小伙伴告诉我说 Current 和 Dispatcher 属性都可能为 null。然而实际上这里只可能 Current 为 null 而此上下文的 Dispatcher 是绝对不会为 null 的。(当然我们这里讨论的是常规编程手段,如果非常规手段,你甚至可以让实例的 this 为 null 呢……)当你的应用程序退出时...

原文地址: https://blog.walterlv.com/post/application-current-may-be-null.html

收录时间: 2019-08-27 浏览量: 2538 分类: WPF

| 0 收藏 | 0