zoukankan      html  css  js  c++  java
  • C#委托事件实例

    public delegate void TimeoutHandler(int connectID);

    public class UserOnLineChecker

    {

      public event TimeoutHandler SomeConnectionTimeOuted;

      private Timer timerForCheckOnLine;

      public UserOnLineChecker()

      {

        this.SomeConnectionTimeOuted = null;

      }

      private void OnLineCheckAction(object state)
          {

        if (this.SomeConnectionTimeOuted != null)
                {
                    this.SomeConnectionTimeOuted(state as int);
                }

      }

      public void Start()
           {
                this.timerForCheckOnLine = new Timer(new TimerCallback(this.OnLineCheckAction), null, 3* 60000, 3 * 60000);
            }

    }

    调用:

    public class UserLogin

    {

      private UserOnLineChecker tcpUserOnLineChecker;

      public UserLogin()

      {

          this.tcpUserOnLineChecker = new UserOnLineChecker();
                    //this.tcpUserOnLineChecker.Initialize(this.onLineCheckSpan);
                    this.tcpUserOnLineChecker.SomeConnectionTimeOuted += new TimeoutHandler(this.tcpUserOnLineChecker_SomeConnectionTimeOuted);

      }

      private void tcpUserOnLineChecker_SomeConnectionTimeOuted(int connectID)
            {

          //处理回调事件
              }

      public void Start()
            {
                this.tcpUserOnLineChecker.Start();//调用UserOnLineChecker类中委托注册事件方法
            }

    }

  • 相关阅读:
    Delphi异常处理try except语句和try finally语句用法以及区别
    test
    Infopath resource
    C# IDE
    操作数据库
    不同版本数据库的导入
    workflow for sharepoint 2007
    http://www.cnblogs.com/BearStudyHard/archive/2008/03/26/1123267.html
    深入浅出InfoPath——安装VSTO
    如何使用Lotuscript管理Excel中的工作表?
  • 原文地址:https://www.cnblogs.com/fx2008/p/2244535.html
Copyright © 2011-2022 走看看