1111
This commit is contained in:
63
Object/Timer/Timer.md
Normal file
63
Object/Timer/Timer.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# Timer 类函数文档
|
||||
|
||||
**类说明**:
|
||||
`Timer`类为定时器相关操作。
|
||||
|
||||
|
||||
---
|
||||
|
||||
### 函数签名
|
||||
**公有函数**:
|
||||
- `function SetTimeOut(target_func, delay_time, ...)`
|
||||
### 参数
|
||||
- `target_func`:函数体,要获执行的函数
|
||||
- `delay_time`:整数,要延迟的时间(秒)
|
||||
- `...`:可变参数,传入的参数可再函数体回调函数中使用
|
||||
|
||||
|
||||
**这里给出两个个例子**:
|
||||
> 无参数
|
||||
```
|
||||
Timer.SetTimeOut(function() {
|
||||
print("注册 5 秒后执行")
|
||||
}, 5);
|
||||
```
|
||||
---
|
||||
> 有参数
|
||||
```
|
||||
Timer.SetTimeOut(function(str,num) {
|
||||
print(str);//将打印 "字符串"
|
||||
print(num);//将打印 123
|
||||
print("注册 5 秒后执行")
|
||||
}, 5,"字符串",123);
|
||||
```
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
### 函数签名
|
||||
**公有函数**:
|
||||
- `function SetCronTask(target_func, CronString, ...)`
|
||||
### 参数
|
||||
- `target_func`:函数体,要获执行的函数
|
||||
- `CronString`:字符串,计划任务格式 让gpt帮你写cron字符串
|
||||
- `...`:可变参数,传入的参数可再函数体回调函数中使用
|
||||
|
||||
|
||||
**这里给出两个个例子**:
|
||||
> 无参数
|
||||
```
|
||||
Timer.SetCronTask(function() {
|
||||
print("注册 每五秒 执行")
|
||||
}, "*/5 * * * * ?");
|
||||
```
|
||||
---
|
||||
> 有参数
|
||||
```
|
||||
Timer.SetCronTask(function(str,num) {
|
||||
print(str);//将打印 "字符串"
|
||||
print(num);//将打印 123
|
||||
print("注册 每五秒 执行")
|
||||
}, "*/5 * * * * ?","字符串",123);
|
||||
```
|
||||
---
|
||||
Reference in New Issue
Block a user