C#作的计时器
来源:互联网 发布:梦里花落知多少作者 编辑:程序博客网 时间:2024/05/16 15:25
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace 计时器
{
class TimerExamplState
{
public int counter = 0;
public Timer tmr;
}
class Program
{
static void CheckStatus(object state)
{
TimerExamplState s = (TimerExamplState)state;
s.counter++;
Console.WriteLine("{0}Checking Status {1}",DateTime.Now.TimeOfDay,s.counter);
if(s.counter==5)
{
(s.tmr).Change(1000,2000);
Console.WriteLine("Changed.........");
//Console.WriteLine("disposing of timer.....");
//s.tmr.Dispose();
//s.tmr = null;
}
if (s.counter == 10)
{
//(s.tmr).Change(1000, 1000);
//Console.WriteLine("Changed.......");
Console.WriteLine("disposing of timer.....");
s.tmr.Dispose();
s.tmr = null;
}
}
static void Main(string[] args)
{
TimerExamplState s = new TimerExamplState();
TimerCallback timerDelegate = new TimerCallback(CheckStatus);
Timer timer = new Timer(timerDelegate,s,1000,1000);
s.tmr = timer;
while (s.tmr != null)
Thread.Sleep(0);
Console.WriteLine("Timer finished!");
Console.ReadKey();
}
}
}
- C#作的计时器
- C# 作的状态机
- C#中计时器的实现
- C#简单的计时器代码
- C# 计时器
- C# 计时器
- C# 计时器
- C#计时器
- C# VS 中计时器Timer的误区
- c# 计时器的三种使用方法
- C# 计时器的三种使用方法
- C#计时器的三种实现方法
- C# 计时器的三种使用方法
- C#下操作ini文件的封装
- C#下操作USB设备的方法
- C#下操作USB设备的方法
- c#使用Windows.Forms里面计时器和System.Timers里面的计时器
- C# Timer 计时器 TimerCallback
- [VS] visual studio 2003 快捷键大全
- struts2中怪异问题FileUploadInterceptor拦截器失效。多文件上传中限制文件类
- 常春藤遮身的少女和头戴花冠的青年
- VC6.0编译器参数设置(ZZ)
- gtk教程 linux界面编程
- C#作的计时器
- [ASP] 设置数据的输出格式-使用控件Repeater
- 巨人下半场——记史玉柱校友的创业史
- [ASP] asp.net学习笔记1
- DataGrid动态绑定
- Css 圆角代码
- Error 1603 when trying to deploy packages in Deployment Solution
- [ASP] asp.net学习笔记2
- bcb最佳des加密方法