简单定时器实现

简单定时器实现
; 示例 #4: 使用 method 作为定时器子程序.

counter := new SecondCounter
counter.Start()
Sleep 5000
counter.Stop()
Sleep 2000

; 一个记录秒数的示例类...
class SecondCounter {
    __New() {
        this.interval := 1000
        this.count := 0
        ; Tick() 有一个隐式参数 "this" 引用一个对象
        ; 所以
        ; 我们需要创建一个封装 "this" 和 Tick 方法的函数来调用:
        this.timer := ObjBindMethod(this, "Tick")
    }
    Start() {
        ; 已知限制: SetTimer 需要一个纯变量引用.
        timer := this.timer
        SetTimer % timer, % this.interval
        ToolTip % "Counter started"
    }
    Stop() {
        ; 在此之前传递一个相同的对象来关闭定时器:
        timer := this.timer
        SetTimer % timer, Off
        ToolTip % "Counter stopped at " this.count
    }
    ; 本例中,定时器调用了以下方法:
    Tick() {
        ToolTip % ++this.count
    }
}

 

给TA捐赠
共{{data.count}}人
人已捐赠
其他

等待特定的窗口出现, 然后通知用户

2018-1-4 15:31:27

其他

按住鼠标左键拖动时, 在拖动区域中会出现工具提示显示区域的大小

2018-1-4 15:40:30

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索