Esempio n. 1
0
 protected void Application_End(object sender, EventArgs e)
 {
     // 在应用程序关闭时运行的代码
     //解决应用池回收问题
     System.Threading.Thread.Sleep(5000);
     Random          rd             = new Random();
     string          strUrl         = CommonHelp.GetConfig("APITX") + "&r=" + rd.Next();
     HttpWebResponse ResponseDataXS = CommonHelp.CreateHttpResponse(strUrl, null, 0, "", null, "GET");
     string          Returndata     = new StreamReader(ResponseDataXS.GetResponseStream(), Encoding.UTF8).ReadToEnd();
 }
Esempio n. 2
0
        public void TimerNow(object source, System.Timers.ElapsedEventArgs e)
        {
            string path = Environment.CurrentDirectory;

            try
            {
                Random          rd             = new Random();
                string          strUrl         = CommonHelp.GetConfig("APITX") + "&r=" + rd.Next();
                HttpWebResponse ResponseDataXS = CommonHelp.CreateHttpResponse(strUrl, null, 0, "", null, "GET");
                string          Returndata     = new StreamReader(ResponseDataXS.GetResponseStream(), Encoding.UTF8).ReadToEnd();
            }
            catch (Exception ex)
            {
                CommonHelp.WriteLOG(ex.Message.ToString());
            }
        }
Esempio n. 3
0
 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 {
     try
     {
         while (!stoppingToken.IsCancellationRequested)
         {
             Random          rd             = new Random();
             string          strUrl         = Appsettings.app("APITX");
             HttpWebResponse ResponseDataXS = CommonHelp.CreateHttpResponse(strUrl, null, 0, "", null, "GET");
             string          Returndata     = new StreamReader(ResponseDataXS.GetResponseStream(), Encoding.UTF8).ReadToEnd();
             await Task.Delay(5000, stoppingToken); //启动后5秒执行一次 (用于测试)
         }
     }
     catch (Exception ex)
     {
         CommonHelp.WriteLOG(ex.Message.ToString());
     }
 }