• .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
     }
    }

  • 相关阅读:
    A Year Of Books
    Spring Boot 之 RESRful API 权限控制
    Git回滚远程版本
    初探设计:Java接口和抽象类何时用?怎么用?
    深入浅出: Java回调机制(异步)
    深入浅出: 大小端模式
    Java IO 之 FileInputStream & FileOutputStream源码分析
    Java IO 之 OutputStream源码
    软件测试--安装软件
    Mybatis 中$与#的区别
  • 原文地址:https://www.cnblogs.com/winner/p/660234.html
Copyright © 2020-2023  润新知