zoukankan      html  css  js  c++  java
  • .Net定时弹出窗口(c#)

    .Net定时弹出窗口(c#)

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Web;
    using System.Web.SessionState;
    using System.Threading;
    using System.Timers;

    namespace PopUp
    {
     public class Global : System.Web.HttpApplication
     {
      private System.ComponentModel.IContainer components = null;
      private System.Timers.Timer aTimer;
                public static DateTime dtBegin;
      public static long TimeInterval=10000;
      public static bool TimeOut;

      public Global()
      {
       InitializeComponent();
      } 
      
      protected void Application_Start(Object sender, EventArgs e)
      {
       TimeOut=false;
       dtBegin=DateTime.Now;
       aTimer = new System.Timers.Timer();
       aTimer.Elapsed+=new ElapsedEventHandler(OnTimedEvent);
       aTimer.Interval=TimeInterval;
       aTimer.Enabled=true;
      }
     
      protected void Session_Start(Object sender, EventArgs e)
      {
      }

      protected void Application_BeginRequest(Object sender, EventArgs e)
      {
            if (TimeOut==true)
       {
       TimeSpan ts=DateTime.Now-dtBegin;
                      string str="<script>alert('You have been in this application ";
       str=str+ts.Hours+" hours "+ts.Minutes +" minutes "+ts.Seconds +" seconds!')</script>";
       Response.Write(str);
       TimeOut=false;
       }
      }

      protected void Application_EndRequest(Object sender, EventArgs e)
      {
      }

      protected void Application_AuthenticateRequest(Object sender, EventArgs e)
      {
      }

      protected void Application_Error(Object sender, EventArgs e)
      {

      }

      protected void Session_End(Object sender, EventArgs e)
      {
      }

      protected void Application_End(Object sender, EventArgs e)
      {
       this.aTimer.Enabled=false; 
      }

      private void OnTimedEvent(object source, ElapsedEventArgs e)
      {
       TimeOut=true;
      }
       
      #region Web Form Designer generated code
      private void InitializeComponent()
      {   
      }
      #endregion
     }
    }

  • 相关阅读:
    26、实例化需求:团队如何交付正确的软件
    25、华胥引
    24、老子
    23、禅与摩托车维修艺术(又名万里任禅游)
    22、中国哲学简史
    21、人类简史-从动物到上帝(赫拉利)
    20、淘宝技术这十年
    19.验收测试驱动开发
    18. Scrum敏捷软件开发
    17、胡适谈哲学与人生
  • 原文地址:https://www.cnblogs.com/winner/p/660234.html
Copyright © 2011-2022 走看看