如何在c#中使用计时器 [英] how to use the timer in c#

查看:151
本文介绍了如何在c#中使用计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c#中使用定时器控件,所以建议我以哪种方式在我的程序中使用定时器。

i want to use the timer control in the c# so suggest me in which way i can use the timer in my program.

推荐答案

实际上定时器用于你可以在其他工作中以特定的间隔在后端工作。它可以用来在同时处理表单时加载大量数据。
actually timer is used to do work in specific intervals in back end while you can do your other work.It can be used to load huge amount of data while working on the form simultaneously.


使用计时器 class [ ^ ]。


HI


如果您在Windows应用程序上工作..

这段代码可行....



HI
if u r working on windows application..
this code will work....

System.Timers.Timer timer = new System.Timers.Timer(1000); // 10 seconds
       private void Form1_Load(object sender, EventArgs e)
       {

           timer.Elapsed += timer_Elapsed;

           timer.Enabled = true;

       }

       void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
       {
           timer.Enabled = false;
           MessageBox.Show("time out");

       }


这篇关于如何在c#中使用计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆