当前位置:编程学习 > C#/ASP.NET >>

C#怎样监听事件发生的时间

一个Windows窗体上,设计了一个按钮,张三、李四分别在不同时间点击这个按钮,如何让按钮在被点击后十五分钟自动弹出提示 --------------------编程问答--------------------

Thread t=new Thread(new ThreadStart(delegate()
                {

 Thread.Sleep(15*60*1000);
                    this.Invoke(new MethodInvoker(delegate() {
                      MessageBox.Show("十五分钟前点我了");
                    
                    }));
});
 t.IsBackground = true;
 t.Start();

--------------------编程问答--------------------
引用 1 楼 flyer_ren 的回复:

Thread t=new Thread(new ThreadStart(delegate()
                {

 Thread.Sleep(15*60*1000);
                    this.Invoke(new MethodInvoker(delegate() {
                      MessageBox.Show("十五分钟前点我了");
                    
                    }));
});
 t.IsBackground = true;
 t.Start();


Sleep基本可以用了,如果你要准确时间的话就不行。。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,