弱鸡,C# System.Timers.Timer测试
来源:互联网 发布:http默认端口号 编辑:程序博客网 时间:2024/06/08 05:37
using System;using System.Threading;using System.Timers;namespace ConsoleApplication1{ class Program { static System.Timers.Timer timer; private static int index = 0; static void Main(string[] args) { Thread thread = new Thread(NewThread); thread.Start(); timer = new System.Timers.Timer(10000) {Enabled = true}; timer.Elapsed += Print; Console.Read(); } private static void NewThread() { Console.WriteLine("进入线程,开始睡25S" + DateTime.Now.ToLocalTime()); Thread.Sleep(25000); Console.WriteLine("25S睡过,停止timer" + DateTime.Now.ToLocalTime()); timer.Stop(); Thread.Sleep(3000); Console.WriteLine("再睡3S,再启动timer" + DateTime.Now.ToLocalTime()); timer.Start(); } private static void Print(object sender, ElapsedEventArgs e) { Console.WriteLine("index = 第" + index + " 次 " + DateTime.Now.ToLocalTime()); index++; } }}
阅读全文
0 0
- 弱鸡,C# System.Timers.Timer测试
- C# System.Timers.Timer用法
- 在C#中使用System.Timers.Timer
- 在C#中使用System.Timers.Timer
- 在C#中使用System.Timers.Timer
- C#中System.Timers.Timer的使用
- System.Timers.Timer
- System.Timers.Timer用法
- 关于System.Timers.Timer
- System.Timers.Timer
- SYstem.Timers.Timer用法
- System.Timers.Timer重置
- System.Timers.Timer和System.Windows.Forms.Timer区别-测试笔记
- System.Timers.Timer 定时执行
- System.Timers.Timer 定时执行
- System.Timers.Timer的使用
- Timer(System.Timers) 和 DispatcherTimer
- 使用System.Timers.Timer类
- Refletion2017.9.4
- 数据结构线性表
- TOPGP5.3:combobox动态下拉
- HDU 6186 前缀后缀
- c++调用shell & shell调用python
- 弱鸡,C# System.Timers.Timer测试
- CodeForces 431# div.2 A Odds and Ends 暴力 贪心
- virtual box虚拟机安装+ubuntu14.04系统安装+GCC4.8编译器安装
- 城市正视图,紫书P132UVa221
- HDU —2012 素数判定
- python 模拟链表
- 简单的分割法
- javax.imageio.IIOException: Can't create output stream解决方法
- IDEA下载安装/破解/配置