using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ThreadTimerExam
{
    class Program
    {
        static void Main(string[] args)
        {
            var timer = new System.Threading.Timer(TimerAction, null, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3));
            Thread.Sleep(15000);
            timer.Dispose();
            Console.Read();
        }
        static void TimerAction(object obj)
        {
            Console.WriteLine("System.Threading.Timer {0:T}", DateTime.Now);
        }
    }
}

C# System.Threading.Timer的使用的更多相关文章

  1. System.Threading.Timer 定时器的用法

    System.Threading.Timer 是C# 中的一个定时器,可以定时(不断循环)执行一个任务.它是在线程上执行的,具有很好的安全性.为此  .Net Framework 提供了5个重载的构造 ...

  2. C# System.Threading.Timer 使用方法

    public class TimerHelper { System.Threading.Timer timer; public TaskSendMMS tasksendmms { get; set; ...

  3. System.Threading.Timer使用心得

    System.Threading.Timer 是一个使用回调方法的计时器,而且由线程池线程服务,简单且对资源要求不高. "只要在使用 Timer,就必须保留对它的引用."对于任何托 ...

  4. System.Threading.Timer 使用

    //定义计时器执行完成后的回调函数 TimerCallback timecallback = new TimerCallback(WriteMsg); //定义计时器 System.Threading ...

  5. System.Threading.Timer的使用技巧

    转自:http://www.360doc.com/content/11/0812/11/1039473_139824496.shtml# System.Threading.Timer timer = ...

  6. System.Threading.Timer如何正确地被Dispose

    System.Threading.Timer是.NET中一个定时触发事件处理方法的类(本文后面简称Timer),它背后依靠的是.NET的线程池(ThreadPool),所以当Timer在短时间内触发了 ...

  7. System.Windows.Forms.Timer、System.Timers.Timer、System.Threading.Timer的 区别和用法

    System.Windows.Forms.Timer执行的时候,如果你在过程中间加一个sleep整个的界面就死掉了,但是另外两个没有这个情况,System.Timers.Timer.System.Th ...

  8. System.Threading.Timer

    GLog.WLog("_thdTimer before"); _thdTimer = new System.Threading.Timer(new TimerCallback(Ti ...

  9. 当时钟事件声明为过程变量 让system.threading.timer时钟失效

    这个项目的小模块就是画label 控件到tablepayoutpanel表单 之中, 中间用到了时钟,事件(带返回值的),哈希表 .由于时钟定义在 form1的启动构造函数中导致了form1,启动完毕 ...

  10. c# 多线程之-- System.Threading Timer的使用

    作用:每隔多久去执行线程里的方法. class ThreadTimerDemo { static void Main(string[] args) { // Create an AutoResetEv ...

随机推荐

  1. Unity3D资源管理架构

    在Unity3D引擎中,场景资源文件(.unity)是以2进制格式存储的.但同一时候它也有一种基于文本的表现格式. 可在Edit>Project Setting>Editor 中设置: 1 ...

  2. C++实现简单的内存块自己主动管理

    #ifndef __MEM__H #define __MEM__H #include<iostream> using namespace std; //自己主动管理内存块 typedef ...

  3. Snmp linux

    http://blog.csdn.net/youngqj/article/details/7311849 http://blog.csdn.net/howema/article/details/418 ...

  4. 全栈JavaScript之路( 二十五 )訪问元素的样式

    不论什么支持style 特性的元素在 ,在其DOM  节点 对象中都有一个 style 属性与之相应. 这个style 对象是 CSSStyleDeclaration类型的实例,包括着html sty ...

  5. C++/Php/Python/Shell 程序按行读取文件或者控制台方法总结。

    C++/Php/Python/Shell 程序按行读取文件或者控制台方法总结. 一.总结 C++/Php/Python/Shell 程序按行读取文件或者控制台(php读取标准输入:$fp = fope ...

  6. [NPM] Create a bash script to replace a complex npm script

    In this lesson we will look at pulling out complex npm scripts into their own external bash scripts. ...

  7. QQ欢乐豆斗地主心得体会(四):合谋赢豆

    刚刚又在玩QQ欢乐斗地主,只可惜,这次不够欢乐. 本金,300万豆,运气比较好,赢到将近400万.突然,形势急转直下,一直输,一直到180多万豆.本来这一局,有硬炸在手,但是没有癞子,基本被吊打的节奏 ...

  8. Oracle数据库零散知识07 -- Materialized view(转)

    物化视图是一种特殊的物理表,“物化”(Materialized)视图是相对普通视图而言的.普通视图是虚拟表,应用的局限性大,任何对视图的查询,Oracle都实际上转换为视图SQL语句的查询.这样对整体 ...

  9. 判断navigation中父控制器类型

    for (UIViewController *controller in self.navigationController.viewControllers) { if ([controller is ...

  10. java中<T> T和T的区别?

    如果你希望 getMax 方法的返回值类型为 T,就要这样去定义getMax方法: public T getMax() 如果你希望 getMax 方法返回值的类型由调用者决定,那么就这么去定义 get ...