通过线程实时获取当前时间
来源:互联网 发布:淘宝试用的东西要还吗 编辑:程序博客网 时间:2024/04/28 18:06
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Threading;namespace com{ public partial class FrmDemo2 : Form { public FrmDemo2() { InitializeComponent(); this.Init(); } protected void Init() { this.Text = "使用System.Threading.Timer动态显示当前时间"; //Callback:一个 TimerCallback 委托,表示要执行的方法。 //State:一个包含回调方法要使用的信息的对象,或者为空引用(Visual Basic 中为 Nothing)。 //dueTime:调用 callback 之前延迟的时间量(以毫秒为单位)。指定 Timeout.Infinite 以防止计时器开始计时。指定零 (0) 以立即启动计时器。 //Period:调用 callback 的时间间隔(以毫秒为单位)。指定 Timeout.Infinite 可以禁用定期终止。 System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(run), null, 0, 1000); this.labTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } private void run(object obj) { if (this.labTime.InvokeRequired) { delSetTime delsettime = new delSetTime(setTime); this.Invoke(delsettime); } else { this.labTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } } protected delegate void delSetTime(); private void setTime() { this.labTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } }}
0 0
- 通过线程实时获取当前时间
- js实时获取当前时间
- [置顶] js实时获取系统当前时间
- js实时获取当前系统时间
- 通过JS获取前台当前系统时间
- 通过js获取当前时间,并格式化
- js实时获取并显示当前时间的方法
- MySQL通过sql语句获取当前日期|时间|时间戳
- java通过当前时间获取系统的往后时间
- MySQL通过sql语句获取当前日期|时间|时间戳
- MySQL通过sql语句获取当前日期|时间|时间戳
- 网页中通过JavaScript 获取当前系统日期和时间
- perl在linux下通过date获取当前时间
- ExtJS通过一行代码获取当前时间的前一天
- FFmpeg通过PTS获取当前帧所在的毫秒时间
- 微信开发如何通过关键词获取当前时间
- php实时显示当前时间
- opencv 实时显示当前时间
- 回顾苹果Macintosh的进化史
- HDU 2546 饭卡 【入门DP之01背包问题】
- Android 系统发送短信给多个联系人使用
- std fstream小例子
- 整理的超级全,且不断更新的机器学习、计算机视觉,自然语言处理库~
- 通过线程实时获取当前时间
- Backup Raspbx system
- POJ 2388(快排)
- Android Binder机制浅析
- ios http 抓包工具mitmproxy 模拟器及真机使用。
- DP------Jump Game
- 数学建模Word排版——项目编号
- chmod 777修改权限指令介绍
- Educational Codeforces Round 6(E)DFS序,线段树