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. centos下添加环境变量和启动apache

    #修改环境变量文件 vi /etc/profile #文件内容末尾添上 PATH=/usr/local/php/bin:$PATH export PATH #修改后让环境变量生效 source /et ...

  2. ValidateRequest="false" 无效

    在做牛腩新闻发布系统的时候,部分同学可能会遇到这样的情况: 从客户端(ContentPlaceHolder1_m_ContentPlaceHolder_ftbContent="<P&g ...

  3. Linux 内存管理子系统

    一.内存管理子系统 1 . 内存管理模块 功能: 虚拟地址到物理地址的映射 32位系统访问的地址一共4G: 0-3G : 应用程序 3G+896M :直接映射 , Vmollat区,永久内存映射,固定 ...

  4. 10 Interesting Linux Command Line Tricks and Tips Worth Knowing

    I passionately enjoy working with commands as they offer more control over a Linux system than GUIs( ...

  5. C之文件读写

    1.fopen() fopen的原型是:FILE *fopen(const char *filename,const char *mode),fopen实现三个功能:为使用而打开一个流,把一个文件和此 ...

  6. Sharepoint 2013 安装部署系列篇 第三篇 -- 安装和配置网络负载均衡在前端web服务器

    第一部分 系统集群安装 第二部分 SQL集群安装 第四部分 安装和配置sharepoint 场(三层拓扑部署) 接下来一步一步开始配置NLB吧, 以下开始讲解如何配置NLB集群作为sharepoint ...

  7. javaShop的一些总结

    主要参考 pdf 找到对应的文件吧,具体怎么制作一个挂件 还没有理解里面的思路,就没有研究了,改一个商城项目遇到了,也只有慢慢解决 加油! CSDN下载地址:http://download.csdn. ...

  8. MongoDB - MongoDB CRUD Operations

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

  9. (转)Android之接口回调机制

    开发中,接口回调是我们经常用到的. 接口回调的意思即,注册之后并不立马执行,而在某个时机触发执行. 举个例子: A有一个问题不会,他去问B,B暂时解决不出来,B说,等我(B)解决了再告诉你(A)此时A ...

  10. sql Truncate 与 delete的区别

    Truncate 语法 TRUNCATE TABLE     [ { database_name .[ schema_name ] . | schema_name . } ]     table_na ...