惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 笑萧亦然

KingdeeK3-修改单据邮件发送的自定义字段 微软在GitHub上开放源代码 【转】GitHub入门详细讲解 asp.net 导出excel 中文乱码解决方法 (转) C#自动切换Windows窗口程序,如何才能调出主窗口? 系统颜色对照表 showModalDialog后如何刷新父页面 常用SQL关于表的操作 System.Web.HttpException 与 HTTP Error 404.13 - Not Found问题解决说明 SQL 数据库常用的系统存储过程解析 JAVA md5把我气到疯的代码,天哪,神呀,我的C# 啊。 根据经纬度坐标计算两点间几何距离 - 椰子树下 - CSDN博客 获取库中的所有字段的描述/获取某个表中所有字段方法 多个CSS风格共用同一(背景)图片_那一片天_百度空间 学习总结之三(SQL SERVER游标CURSOR的使用) SQL Server 如何锁一个表的某一行 - MS-SQL Server / 基础类 SQL中的系统变量一览 简单的弹出层窗口应用(DIV+JS) - 笑萧亦然 - 博客园 sql中左侧不够自动补0的写法,优!
delegate Demo (一个关于System.Timers.Timer的Demo)
笑萧亦然 · 2013-04-25 · via 博客园 - 笑萧亦然
namespace Delegates
{
    partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            clock = new Clock(digital);
        }

        private void start_Click(object sender, System.EventArgs e)
        {
            this.clock.Start();
        }

        private void stop_Click(object sender, System.EventArgs e)
        {
            this.clock.Stop();
        }

        private Clock clock;
    }
}

Clock.cs类的内容

namespace Delegates
{
    using System.Windows.Forms;

    class Clock
    {
        public Clock(TextBox displayBox)
        {
            this.display = displayBox;
        }

        public void Start()
        {
            pulsed.Add(this.RefreshTime);
        }

        public void Stop()
        {
            pulsed.Remove(this.RefreshTime);
        }

        private delegate void InvokeCallback(string msg);
        private void RefreshTime(int hh, int mm, int ss)
        {
            if (!this.display.InvokeRequired)
            {
                this.display.Text = string.Format("{0:D2}:{1:D2}:{2:D2}", hh, mm, ss);
            }
            else
            {
                InvokeCallback msgCallback = new InvokeCallback(DisplayText);
                display.Invoke(msgCallback, new object[] { string.Format("{0:D2}:{1:D2}:{2:D2}", hh, mm, ss) });

            }

        }

        private void DisplayText(string text)
        {
            this.display.Text = text;
        }

        private Ticker pulsed = new Ticker();
        private TextBox display;



    }
}
namespace Delegates
{
    using System.Collections;
    using System.Timers;
    using System.Windows.Forms;

    class Ticker
    {
        public delegate void Tick(int hh, int mm, int ss);

        public Ticker()
        {
            this.ticking.Elapsed += new ElapsedEventHandler(this.OnTimedEvent);
            this.ticking.Interval = 1000; // 1 second
            this.ticking.Enabled = true;
        }

        public void Add(Tick newMethod)
        {
            this.tickers += newMethod;
        }

        public void Remove(Tick oldMethod)
        {
            this.tickers -= oldMethod;
        }

        private void Notify(int hours, int minutes, int seconds)
        {
            if (this.tickers != null)
            {
                this.tickers(hours, minutes, seconds);
            }

        }

        private void OnTimedEvent(object source, ElapsedEventArgs args)
        {
            int hh = args.SignalTime.Hour;
            int mm = args.SignalTime.Minute;
            int ss = args.SignalTime.Second;
            Notify(hh, mm, ss);
        }

        private Tick tickers;
        private System.Timers.Timer ticking = new System.Timers.Timer();
    }
}

Ticker.cs类的内容