wpf 登录时显示状态动态图
下面的示例演示了如何在登录过程时,界面上显示状态图标,登录完成后隐藏图标:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
} private void Window_Loaded(object sender, RoutedEventArgs e)
{
Thread th1 = new Thread(Method1);
th1.Start(); // show progressbar
progressBar.Visibility = Visibility.Visible;
} void Method1()
{
MessageBox.Show("starting"); // process your work...
Thread.Sleep(); MessageBox.Show("ending"); // hide progressbar
this.Dispatcher.BeginInvoke(new Action(() => { progressBar.Visibility = Visibility.Collapsed; }));
}
}
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">
<Grid>
<Image x:Name="progressBar" Height="50" Width="50" Visibility="Collapsed" gif:ImageBehavior.RepeatBehavior="Forever" gif:ImageBehavior.AnimatedSource="/progress.gif" />
</Grid>
</Window>
In WPF, a DispatcherObject can only be accessed by the Dispatcher it is associated with. For example, a background thread cannot update the contents of a Button that is associated with the Dispatcher on the UI thread. In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. This is accomplished by using either Invoke or BeginInvoke. Invoke is synchronous and BeginInvoke is asynchronous. The operation is added to the queue of the Dispatcher at the specified DispatcherPriority.
If BeginInvoke is called on a Dispatcher that has shut down, the status property of the returned DispatcherOperation is set to Aborted.
All of the methods on Dispatcher, with the exception of DisableProcessing, are free-threaded.
Objects that derive from DispatcherObject have thread affinity.
相关资源:https://docs.microsoft.com/en-us/dotnet/api/system.windows.threading.dispatcher?view=netframework-4.8
wpf 登录时显示状态动态图的更多相关文章
- [置顶] Android中使用Movie显示gif动态图
转载请注明: http://blog.csdn.net/u012975705/article/details/48717391 在看这篇博文之前对attr自定义属性还是不是很熟的童鞋可以先看看:An ...
- jsp利用cookie记住用户名,下次登录时显示在文本框中(仅仅一个Cookie就整了将近三个小时,⊙﹏⊙b汗)
<%@page import="java.net.URLDecoder"%> <%@page import="sun.security.util.Len ...
- 在Linux下sqlplus 登录时显示SID 和用户名
一般显示为: SQL> show user USER 为 "SYS" SQL> 在 $ORACLE_HOME/sqlplus/admin目录下 编辑glogin.sql ...
- python,tensorflow线性回归Django网页显示Gif动态图
1.工程组成 2.urls.py """Django_machine_learning_linear_regression URL Configuration The ` ...
- 登录时显示403 Access Denied
用户名及密码设置如下: 在tomcat安装目录\conf\tomcat-users.xml中的<tomcat-users>标签内设置: <role rolename="ma ...
- C# 动态创建SQL数据库(二) 在.net core web项目中生成二维码 后台Post/Get 请求接口 方式 WebForm 页面ajax 请求后台页面 方法 实现输入框小数多 自动进位展示,编辑时实际值不变 快速掌握Gif动态图实现代码 C#处理和对接HTTP接口请求
C# 动态创建SQL数据库(二) 使用Entity Framework 创建数据库与表 前面文章有说到使用SQL语句动态创建数据库与数据表,这次直接使用Entriy Framwork 的ORM对象关 ...
- 【Python】模块学习之matplotlib柱状图、饼状图、动态图及解决中文显示问题
前言 众所周知,通过数据绘图,我们可以将枯燥的数字转换成容易被人们接受的图表,从而让人留下更加深刻的印象.而大多数编程语言都有自己的绘图工具,matplotlib就是基于Python的绘图工具包,使用 ...
- vue-element-admin登录逻辑,以及动态添加路由,显示侧边栏
这段时间在研究element-admin,感觉这个库有许多值得学习的地方,我学习这个库的方法是,先看它的路由,顺着路由,摸清它的逻辑,有点像顺藤摸瓜. 这个库分的模块非常清晰,适合多人合作开发项目,但 ...
- Wpf 中使用gif格式的动态图
第一种方法:使用winform插件 <WindowsFormsHost xmlns:wf="clr-namespace:System.Windows.Forms;assembly=S ...
随机推荐
- Leetcode96.Unique Binary Search Trees不同的二叉搜索树
给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种? 示例: 输入: 3 输出: 5 解释: 给定 n = 3, 一共有 5 种不同结构的二叉搜索树: 假设n个节点存在二叉排序树的 ...
- LUOGU P2964 [USACO09NOV]硬币的游戏A Coin Game
题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...
- web前端学习常用网址记录
jetbrains下载各种软件和试用 www.jetbrains.com www.jetbrains.com/idea php服务器下载 php文档查询 php.net webAPI网站(各种教程文档 ...
- 通过pip工具安装selenium(初次安装、升级、降级)
1.初始安装 语法: install selenium==版本号 2.升级安装 3.降级安装 ----------------------------------------------------- ...
- Katalon系列二十一:用例中语句失败处理
假如有一个用例:1.登陆2.下单3.对历史单评价4.退出 情况一:当第1步执行失败时,我们希望用例不再执行,因为再执行也没有意义了,反而浪费时间:情况二:当第2步执行失败时,我们希望能略过第2步操作, ...
- 一眼看穿👀JS基本概念
前段时间忙,好久没更新了,继续梳理基础知识这期总结的是JS的基本概念 标识符 所谓的标识符是指变量,函数属性的名字,或者函数的参数 第一个字符必须是一个字母,下划线(_)或者一个美元符号($),其他字 ...
- 会话技术之cookie(记录当前时间、浏览记录的记录和清除)
cookie 会话技术: 当用户打开浏览器的时候,访问不同的资源,直到用户将浏览器关闭,可以认为这是一次会话. 作用: 因为http协议是一个无状态的协议,它不会记录上一次访问的内容.用户在访问过程中 ...
- $.extend用法详解(一)
jQuery.extend( target [, object1 ] [, objectN ] ) 在这里target是Object,它有两个作用: 1. 如果后面没有对应的object1及objec ...
- 【转载】【技巧总结】PyCharm怎么克隆github上开源的项目
PyCharm怎么clone github上开源的项目 一.先要确保PyCharm正确的配置了Git 如果你已经在PyCharm中配置好了Git,可以跳过此步骤,直接看下一步. 那么怎么在Py ...
- js(jquery)鼠标移入移出事件时,出现闪烁、隐藏显示隐藏显示不停切换的情况
<script> $(".guanzhu").hover(function(){ $(".weixinTop").show(); },functio ...