2018-8-10-win10-uwp-Window.Current.Dispatcher中Current为null
title | author | date | CreateTime | categories |
---|---|---|---|---|
win10 uwp Window.Current.Dispatcher中Current为null
|
lindexi
|
2018-08-10 19:16:53 +0800
|
2018-2-13 17:23:3 +0800
|
Win10 UWP
|
本文说的是进行网络中异步界面出现的错误,可能带有一定的主观性和局限性,说的东西可能不对或者不符合每个人的预期。如果觉得我有讲的不对的,就多多包含,或者直接关掉这篇文章,但是请勿生气或者发怒吐槽,可以在我博客评论 http://blog.csdn.net/lindexi_gd
我们可以在修改属性使用
public abstract class NotifyPropertyChangedBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged; protected async void OnPropertyChanged([CallerMemberName] string propName = "")
{
await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.High,
() =>
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
});
}
}
在老周博客:http://www.cnblogs.com/tcjiaan/p/5511419.html
但是我发现在 HttpRequest 中的函数出发了 OnPropertyChanged,这时发现 Current is null
并且:public event PropertyChangedEventHandler PropertyChanged;中 PropertyChanged 也是null
老周:由于线程出现嵌套,在Get请求回调的时候,窗口线程已由系统调整。就按你的做法,用主视图层上的调度对象来调用,应用程序级别的视图线程一般不会改变。
要么改用HttpClient类的异步方法来请求,是Windows.Web.Http下面的类,非.net core类型
简单方法:
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { });
2018-8-10-win10-uwp-Window.Current.Dispatcher中Current为null的更多相关文章
- win10 uwp Window.Current.Dispatcher中Current为null
本文说的是进行网络中异步界面出现的错误,可能带有一定的主观性和局限性,说的东西可能不对或者不符合每个人的预期.如果觉得我有讲的不对的,就多多包含,或者直接关掉这篇文章,但是请勿生气或者发怒吐槽,可以在 ...
- WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null
原文:WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null 在 WPF 程序中,可能会存在 Application.Current.D ...
- WPF 的 Application.Current.Dispatcher 中,Dispatcher 属性一定不会为 null
原文:WPF 的 Application.Current.Dispatcher 中,Dispatcher 属性一定不会为 null 在 WPF 程序中,可能会存在 Application.Curren ...
- win10 uwp win2d CanvasVirtualControl 与 CanvasAnimatedControl
本文来告诉大家 CanvasVirtualControl ,在什么时候使用这个控件. 在之前的入门教程win10 uwp win2d 入门 看这一篇就够了我直接用的是CanvasControl,实际上 ...
- win10 uwp 获得元素绝对坐标
有时候需要获得一个元素,相对窗口的坐标,在修改他的位置可以使用. 那么 UWP 如何获得元素坐标? 我提供了一个方法,可以获得元素的坐标. 首先需要获得元素,如果没有获得元素,那么如何得到他的坐标? ...
- win10 uwp 渲染原理 DirectComposition 渲染
本文来告诉大家一个新的技术DirectComposition,在 win7 之后(实际上是 vista),微软正在考虑一个新的渲染机制 在 Windows Vista 就引入了一个服务,桌面窗口管理器 ...
- Win10 UWP开发系列:实现Master/Detail布局
在开发XX新闻的过程中,UI部分使用了Master/Detail(大纲/细节)布局样式.Win10系统中的邮件App就是这种样式,左侧一个列表,右侧是详情页面.关于这种 样式的说明可参看MSDN文档: ...
- 【Win10 UWP】QQ SDK(二):SDK的回调处理
上一讲,我们介绍了QQ SDK的使用方法,请看<[Win10 UWP]QQ SDK(一):SDK基本使用方法> 一. 回调的基本形式 从前面的介绍中我们知道,我们的应用和QQ客户端之间需要 ...
- win10 uwp MVVM 轻量框架
如果在开发过程,遇到多个页面之间,需要传输信息,那么可能遇到设计的问题.如果因为一个页面内包含多个子页面和多个子页面之间的通信问题找不到一个好的解决方法,那么请看本文.如果因为ViewModel代码越 ...
随机推荐
- oracle 共享服务器监控
1. 观察sga的使用情况 select * from v$sgastat where pool=’large pool’; 2. 观察调度程序是否充足: 首先看每个调度程序的忙闲: sele ...
- oracle-ORA-00942错误
表或视图不存在 原因:1.表或视图真的不存在 2.用户没有访问该表的权限. ORA-01078: 处理系统参数失败 ORA-01438: value larger than specified pre ...
- 集合--List&&ArrayList-LinkedList
1.8新特性 List接口中的replaceAll()方法,替换指定的元素,函数式接口编程 List 元素是有序的并且可以重复 四种add();方法 ArrayList(用于查询操作),底层是数组 ...
- phpexcel使用说明5----ThinkPHP+PHPExcel[导入][导出]实现方法
转自:http://www.thinkphp.cn/code/403.html实现步骤: 注意:phpexcel必须是1.78版本的,不能用1.8以上的 一:去官网http://phpexcel.co ...
- 命令行的形式运行php
转自:http://www.cnblogs.com/myjavawork/articles/1869205.html 注意:在安装php时需要将php 的安装目录加到环境变量 PATH 中 (右击我的 ...
- Flask_Migrate数据库迁移
migrate数据库迁移 有models,没有迁移仓库.本地新建数据库:首次创建迁移仓库.迁移脚本:执行迁移脚本生成数据库表: python manage.py db init python mana ...
- 微信服务号获得openid 跟用户信息
https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxxxxxxxxx&redirect_uri=http://www. ...
- @atcoder - AGC034D@ Manhattan Max Matching
目录 @description@ @solution@ @accepted code@ @details@ @description@ 考虑一个二维平面,执行共 2*N 次操作: 前 N 次,第 i ...
- LeetCode80 Remove Duplicates from Sorted Array II
题目: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? (Mediu ...
- js中字符串拼接html
1.使用转义字符 ": " " "+userName+" " " 效果:"userName" 2. 单引号中拼 ...