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

  • 相关阅读:
    开源魔兽世界私服搭建
    centos7 普通用户无法使用ssh登录其他服务器
    Java时间格式大全
    C#中的线程之Abort陷阱
    C# 多线程学习系列四之ThreadPool取消、超时子线程操作以及ManualResetEvent和AutoResetEvent信号量的使用
    C# ThreadPool类(线程池)
    VS2019输出信息到调试控制台
    Stream/Bytes[]/Image对象相互转化
    Asp.NetCore 读取配置文件帮助类
    Java SpringBoot使用126邮箱发送html内容邮件,带附件
  • 原文地址:https://www.cnblogs.com/winner/p/660234.html
Copyright © 2011-2022 走看看