在ASP.NET C#中创建常规计时器 [英] Create general timer in ASP.NET C#

查看:79
本文介绍了在ASP.NET C#中创建常规计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。




我创建ASP.net Web应用程序。我的应用程序需要检查每个Web服务5分钟。

开发人员的所有内容都可以,但在IIS中创建两个定时器任何工作做两次。

请帮助我。



我尝试了什么:



我创建静态Timer(System.Timers.Timer)类和将间隔设置为5分钟。

Hi everyone.


I am create ASP.net Web Application .my Application Need to check one web service each 5 Minuts.
everything in Developer is ok , but in IIS Creates two timers an any work Do two times.
Please Help me.

What I have tried:

I am create static Timer (System.Timers.Timer) Class and set interval to 5 minuts.

推荐答案

private System.Windows.Forms.Timer timer5mins; 

    private void FiveMin(){
        timer5mins= new System.Windows.Forms.Timer();
        timer5mins.Tick += new EventHandler(timer5mins_Tick);
        timer5mins.Interval = 1000; // 1 second
        timer5mins.Start(); 
    }

    private void timer5mins_Tick(object sender, EventArgs e)
    {
          //Call Webservice Method
         //You can either ReCALL FiveMin Function Again to never stop
        //Or
       // Use timer5mins.Stop(); 
    }


这篇关于在ASP.NET C#中创建常规计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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