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

  • 相关阅读:
    python 字典
    python set集合
    python封装和解构
    python 内置数据结构 切片
    CPU 上下文切换及案例分析
    怎么理解linux的平均负载及平均负载高后的排查工具
    Linux性能优化
    python 内置数据结构 字符串
    python内置数据结构
    python GC、分支、循环
  • 原文地址:https://www.cnblogs.com/youziwulala/p/11550472.html
Copyright © 2011-2022 走看看