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 使用定时器的更多相关文章

  1. WPF中定时器与进度条的配合使用

    WPF中定时器使用的注意事项: WPF需要使用System.Windows.Threading.DispatcherTimer定时器,而不能使用System.Timers.Timer定时器.因为Sys ...

  2. WPF DispatcherTimer(定时器应用) 无人触摸60s自动关闭窗口

    原文:WPF DispatcherTimer(定时器应用) 无人触摸60s自动关闭窗口 如果无人触摸:60s自动关闭窗口 xmal:部分 <s:SurfaceWindow x:Class=&qu ...

  3. WPF中定时器Timer与DispatcherTimer的用法

    最近的工作项目中需要定时更新UI控件中的数据,这时候第一反应肯定会想到去使用System.Timers.Timer定时更新UI控件,但是程序运行后,会发现程序崩溃了.报的异常为“调用线程无法访问此对象 ...

  4. WPF的定时器

    一.注意事项 引用命名空间:System.Windows.Threading.DispatcherTimer. 二.使用方法 var _timer = new DispatcherTimer(); _ ...

  5. WPF c# 定时器

    //定时查询-定时器 DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += (s, e) = ...

  6. WPF单线程定时器 简单实例

    //窗体加载完毕 void MyMessageBox_Loaded(object sender, RoutedEventArgs e) { //启动定时期倒计时,多线程计时 //System.Thre ...

  7. WPF 中定时器的使用

    DispatcherTimer timer; private void Window_Loaded(object sender, RoutedEventArgs e) { timer = new Di ...

  8. C# Wpf异步修改UI,多线程修改UI(二)

    1.使用定时器异步修改 这是相对比较简单的方法 在Wpf中定时器使用DiapatcherTimer,不使用Timer原因: 在一个应用程序中,Timer会重复生成time事件,而DispatcherT ...

  9. C#学习笔记之线程 - 使用线程

    基于事件的异步模式 (EAP -- The Event-Based Asynchronous Pattern) EAP提供了一个简单的办法,通过它的类能够提供多线程能力,而不需显式的开启或管理线程.它 ...

随机推荐

  1. node.js Web应用框架Express.js(一)

    什么是Express.js Express 是一个简洁而灵活的 node.js Web应用框架, 提供一系列强大特性帮助你创建各种Web应用,提供丰富的HTTP工具以及来自Connect框架的中间件随 ...

  2. codeforces 590B B. Chip 'n Dale Rescue Rangers(二分+计算几何)

    题目链接: B. Chip 'n Dale Rescue Rangers time limit per test 1 second memory limit per test 256 megabyte ...

  3. WPF 之 数据绑定

    数据绑定需要: 后台必须要有与控件对应的类和相关的属性 在后台new 一个类的对象 在后台把控件的数据上下文设置为该对象. 在XAML中把要绑定的控件中Text =      "{Bindi ...

  4. MongoDB - MongoDB CRUD Operations

    CRUD operations create, read, update, and delete documents. Create Operations Create or insert opera ...

  5. 人情世故&潜规则

    大凡成功的牛人,无一例外都明白这一点.他们读懂了社会的本质和人际交往的潜规则,知道对方需要什么,知道对方脑子里在想什么.你几乎看不见他奔波劳碌,但是在不动声色中,他就已经实现人生目标.他们成功的密码是 ...

  6. 关于DB2 SQL0805N找不到程序包的错误解决办法

    DB2在执行SQL语句的时候会使用内部定义的包(package)来保持不同级别的游标的稳定性, 包的名字就是“ULLID.SYSLH2XX“. DB2 里面默认的时候会创建3个这样的包即SYSLH20 ...

  7. shell中使用echo命令改变输出显示样式

    文本终端的颜色可以使用“ANSI非常规字符序列”来生成.举例:echo -e "\033[44;37;5m ME \033[0m COOL" 以上命令设置背景成为蓝色,前景白色,闪 ...

  8. 64位Windows7升级IE11后无法启动的解决办法

    1.控制面板\网络和 Internet\Internet选项 2.在高级选项卡的“安全”组配置

  9. 如何安装 JAVA 7 (JDK 7u75) 在 CentOS/RHEL 7/6/5 Fedora

    先下载JDK For 64 Bit:- # cd /opt/ # wget --no-cookies --no-check-certificate --header "Cookie: gpw ...

  10. 动态调用webservice时 ServiceDescriptionImporter类在vs2010无法引用的解决方法

    [导读]ServiceDescriptionImporter是创建Web Service 时使用的类,它是引用继承System.Web.Services 当我将VS2005里写的一段代码放在VS201 ...