zoukankan      html  css  js  c++  java
  • 计时器

    /**************11111************************/

    private timeName: number;
    private isCanClick: boolean;
    private timeNum: number = 10;

    private clickFun(): void {
    let s = this;
    if (s.isCanClick) {
    s.isCanClick = false;

    s.timeName = loopMgr.setInterval(s.timeFun, s, 1000);
    }
    }

    private timeFun(): void {
    let s = this;

    if (s.timeNum <= 0) {
    s.clearTime();
    return;
    }
    s.timeNum--;

    }

    private clearTime(): void {
    let s = this;

    s.timeNum = 10;
    loopMgr.clearInterval(s.timeName);
    s.isCanClick = true;
    }

    /**************222************************/

    private timeIdx: number;

    private times: number = 10000;

    private isCanClick: boolean;

    private checkStatus(): boolean {
    let s = this;
    return s.isCanClick;
    }

    private clearTime(): void {
    let s = this;
    if (s.timeIdx)
    loopMgr.clearTimeOut(s.timeIdx);
    s.timeIdx = null;
    }

    private timeFun(): void {
    let s = this;
    s.isCanClick = false;
    s.timeIdx = loopMgr.setTimeOut(s.setStatus, s, s.times);
    }

    private setStatus(): void {
    let s = this;
    s.isCanClick = true;
    s.clearTime();
    }

    /**************333************************/

    private timeIdx: number;

    private times: number = 10;

    private isCanClick: boolean;

    private checkStatus(): boolean {
    let s = this;
    return s.isCanClick;
    }

    private clearTime(): void {
    let s = this;
    if (s.timeIdx)
    s.timeIdx = null;
    loopMgr.clearInterval(s.timeIdx);
    }

    private timeFun(): void {
    let s = this;
    s.isCanClick = false;
    s.timeIdx = loopMgr.setInterval(s.setStatus, s, 1000);
    /**执行的方法 */
    }

    private setStatus(): void {
    let s = this;
    if (s.times <= 0) {
    s.clearTime();
    s.isCanClick = true;
    s.times = 10;
    return;
    } else {
    s.times--;
    }
    }

  • 相关阅读:
    pyzabbix 接口使用
    lvs使用进阶
    lvs基础
    linux服务基础之nginx配置详解
    linux服务基础之编译安装nginx
    iptables (二) nat & tcp_wrapper
    iptables (一) 主机防火墙和网络防火墙
    rsyslog及loganalyzer
    linux基础之Mini Linux制作
    linux基础之磁盘管理与文件系统
  • 原文地址:https://www.cnblogs.com/youziwulala/p/11550472.html
Copyright © 2011-2022 走看看