WindowsService调用API

您所在的位置:网站首页 来去之间的博客叫什么来着 WindowsService调用API

WindowsService调用API

2024-07-13 15:30| 来源: 网络整理| 查看: 265

namespace WindowsServiceTest {  public partial class ServiceTest : ServiceBase  {        

//计时器必须要是全局      

  System.Timers.Timer timer1;   public ServiceTest()   {    InitializeComponent();   }

        ///

        ///服务开始  

       ///此处需要根据实际情况来决定,如果想让服务调用接口(使用System.Timers.Timer计时器)       

     ///        

   ///

  protected override void OnStart(string[] args)   {        

 

          timer1 = new System.Timers.Timer();

          timer1.Interval = 1200000;  //设置计时器事件间隔执行时间20分钟执行一次          

            timer1.Elapsed += new System.Timers.ElapsedEventHandler(StartIntegrate);

            timer1.Enabled = true;   

  }        

///        

/// 服务结束        

///   

protected override void OnStop()   {                

            }

 

        ///  

       /// 这里是要写入调用接口的方法了

        ///        

///        

///        

public static void StartIntegrateTest(object sender, System.Timers.ElapsedEventArgs e) {

            int  hour = DateTime.Now.Hour;//当前时间  小时

            int  minu = DateTime.Now.Minute;//当前时间 分                      

//判断时间是否为0点整  

           if (hour == 2 && minu



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3