Skip to content

Commit 0ab22a2

Browse files
committed
更正lua定时器积累过多后,定时器不准的bug
1 parent c88d49c commit 0ab22a2

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

changlog/autoUpdate.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<item>
3-
<version>1.0.2.5</version>
4-
<url>https://llcom.papapoi.com/update/1.0.2.5.zip</url>
5-
<changelog>https://llcom.papapoi.com/changelog/1.0.2.5.html</changelog>
3+
<version>1.0.2.6</version>
4+
<url>https://llcom.papapoi.com/update/1.0.2.6.zip</url>
5+
<changelog>https://llcom.papapoi.com/changelog/1.0.2.6.html</changelog>
66
<mandatory mode="1">true</mandatory>
77
</item>

changlog/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
> 欢迎加入交流群:`906307487`
1010

11+
## LLCOM 1.0.2.6
12+
13+
- 更正lua定时器积累过多后,定时器不准的bug
14+
15+
---
16+
1117
## LLCOM 1.0.2.5
1218

1319
- 更正部分线程不安全的代码,大大降低lua定时器报错的概率

llcom/LuaEnv/LuaRunEnv.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,19 @@ public static int StartTimer(int id,int time)
108108
catch { }
109109
}
110110
pool.TryAdd(id, timerToken);
111-
Task.Run(() =>
111+
var timer = new System.Timers.Timer(time);
112+
timer.Elapsed += (sender, e) =>
112113
{
113-
System.Threading.Thread.Sleep(time);
114114
if (timerToken == null || timerToken.IsCancellationRequested)
115115
return;
116-
if (tokenSource.IsCancellationRequested)
116+
if (!isRunning)
117117
return;
118+
pool.TryRemove(id, out _);
118119
addTigger(id);
119-
CancellationTokenSource tc;
120-
pool.TryRemove(id,out tc);
121-
}, timerToken.Token);
120+
((System.Timers.Timer)sender).Dispose();
121+
};
122+
timer.AutoReset = false;
123+
timer.Start();
122124
return 1;
123125
}
124126

llcom/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
5252
//通过使用 "*",如下所示:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.2.5")]
55-
[assembly: AssemblyFileVersion("1.0.2.5")]
54+
[assembly: AssemblyVersion("1.0.2.6")]
55+
[assembly: AssemblyFileVersion("1.0.2.6")]
5656
[assembly: NeutralResourcesLanguage("zh-CN")]
5757

0 commit comments

Comments
 (0)