303-Air724UG(4G全网通GPRS)开发-定时器

<p><iframe name="ifd" src="https://mnifdv.cn/resource/cnblogs/LearnAir724UG" frameborder="0" scrolling="auto" width="100%" height="1500"></iframe></p>

 

程序说明

定义了一个循环定时器,一个一次性定时器.

程序启动后每隔1S打印000000000000000

程序运行5S后打印 1111111111111111, 同时关闭了循环定时器

 

 

 

 

module(...,package.seeall) --固定写法


local timerid=0;--记录定时器ID,用来关闭定时器

--定时器回调函数
local function timerfun1()
    log.info("000000000000000")
end

timerid = sys.timerLoopStart(timerfun1, 1000)--1000ms循环定时器


--定时器回调函数
local function timerfun2()
    log.info("11111111111111111111111111111")

    sys.timerStop(timerid);--关闭1000ms循环定时器
end

sys.timerStart(timerfun2, 5000);--一次性定时器,延时5000ms后执行回调函数

 

posted on 2022-11-23 21:26  广源时代  阅读(131)  评论(0编辑  收藏  举报

导航

支付宝 QQ群