WPF 使用定时器
WPF 使用定时器:
<ProgressBar Height="10" HorizontalAlignment="Left" Margin="288,0,0,189" Name="progressBar1"
VerticalAlignment="Bottom" Width="100" />
后台:
private void button1_Click(object sender, RoutedEventArgs e)
{
Window_Loaded2();
}
private void Window_Loaded2()
{
DispatcherTimer _mainTimer = new DispatcherTimer();
_mainTimer.Interval = TimeSpan.FromSeconds(1);
_mainTimer.Tick += new EventHandler(_mainTimer_Tick);
_mainTimer.IsEnabled = true;
//Timer tmr = new Timer();
//tmr.Interval = 100;
//tmr.Enabled = true;
//tmr.Tick += new EventHandler(tmr_Tick);
}
void _mainTimer_Tick(object sender, EventArgs e)
{
if (progressBar1.Value == progressBar1.Maximum)
progressBar1.Value = 0;
progressBar1.Value++;
}
private void tmr_Tick(object sender, EventArgs e)
{
if (progressBar1.Value == progressBar1.Maximum) progressBar1.Value = 0;
progressBar1.Value++;
}
WPF 使用定时器的更多相关文章
- WPF中定时器与进度条的配合使用
WPF中定时器使用的注意事项: WPF需要使用System.Windows.Threading.DispatcherTimer定时器,而不能使用System.Timers.Timer定时器.因为Sys ...
- WPF DispatcherTimer(定时器应用) 无人触摸60s自动关闭窗口
原文:WPF DispatcherTimer(定时器应用) 无人触摸60s自动关闭窗口 如果无人触摸:60s自动关闭窗口 xmal:部分 <s:SurfaceWindow x:Class=&qu ...
- WPF中定时器Timer与DispatcherTimer的用法
最近的工作项目中需要定时更新UI控件中的数据,这时候第一反应肯定会想到去使用System.Timers.Timer定时更新UI控件,但是程序运行后,会发现程序崩溃了.报的异常为“调用线程无法访问此对象 ...
- WPF的定时器
一.注意事项 引用命名空间:System.Windows.Threading.DispatcherTimer. 二.使用方法 var _timer = new DispatcherTimer(); _ ...
- WPF c# 定时器
//定时查询-定时器 DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += (s, e) = ...
- WPF单线程定时器 简单实例
//窗体加载完毕 void MyMessageBox_Loaded(object sender, RoutedEventArgs e) { //启动定时期倒计时,多线程计时 //System.Thre ...
- WPF 中定时器的使用
DispatcherTimer timer; private void Window_Loaded(object sender, RoutedEventArgs e) { timer = new Di ...
- C# Wpf异步修改UI,多线程修改UI(二)
1.使用定时器异步修改 这是相对比较简单的方法 在Wpf中定时器使用DiapatcherTimer,不使用Timer原因: 在一个应用程序中,Timer会重复生成time事件,而DispatcherT ...
- C#学习笔记之线程 - 使用线程
基于事件的异步模式 (EAP -- The Event-Based Asynchronous Pattern) EAP提供了一个简单的办法,通过它的类能够提供多线程能力,而不需显式的开启或管理线程.它 ...
随机推荐
- 安装 vsftpd
(1)安装vsftpdsudo apt-get install vsftpd (2)配置sudo vi /etc/vsftpd.conf #anonymous_enable=YESlocal_enab ...
- iOS开发libWeChatSDK.a(WXApiObject.o)' does not contain bitcode.
在使用微信分享的时候可能会报错, 报错如下: ld: '/Users/gti/Documents/********/Lib/SDKExport/libWeChatSDK.a(WXApiObject.o ...
- 【转】ConcurrentHashMap完全解析(JDK6/7、JDK8)
转自http://my.oschina.net/hosee/blog/675884 并发编程实践中,ConcurrentHashMap是一个经常被使用的数据结构,相比于Hashtable以及Colle ...
- python字符串反转
最一般的想法就是将字符串先转换成列表,倒置列表,再将列表转换为字符串 s = 'Hello world' l = list(s) l.reverse() python ''.join(l) 而pyth ...
- HTML5移动开发中的meta与link
meta HTML5移动开发中的一些webkit专属头部标签,能够帮助浏览器更好的解析HTML代码,从而为HTML5移动开发提供更好的前端表现与体验 viewport网页缩放 1 <meta n ...
- sql 了解
char,varchar,nvarchar区别 类型 长度 使用说明 长度说明 char(n) 固定长度 索引效率高 程序里面使用trim去除多余的空白 n 必须是一个介于 1 和 8,000 之间 ...
- 跟我一起学习ASP.NET 4.5 MVC4.0(一)(转)
由于上面一个项目使用的是ASP.NET4.0 MVC3.0,在招人的时候发现很多人有听说过MVC,但是却是没用过,对MVC也只是一知半解,最近想给团队成员做一个系统的解说,让大家都可以学习一下ASP. ...
- 【python】python文件和目录操作方法大全(含实例)
转自:http://www.jb51.net/article/48001.htm 一.python中对文件.文件夹操作时经常用到的os模块和shutil模块常用方法.1.得到当前工作目录,即当前Pyt ...
- OpenStack 加入新的节点,创建虚拟机失败的问题
最开始做OpenStack的时候,由于只是为了部署测试用,因此将所有的部分都装在一台单网卡的机器上,费了九牛二虎之力终于部署成功,其中最主要的两块问题出现在以下两个方面: 1:nova.neutron ...
- UI2_视图切换ViewController
// // SubViewController.h // UI2_视图切换 // // Created by zhangxueming on 15/7/3. // Copyright (c) 2015 ...