*
This commit is contained in:
2 files changed
+14
-15
No files matched your search
@@ -19,7 +19,7 @@ public class JsonConfigProvider : IConfigProvider {
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑添加 'required' 修饰符或声明为可以为 null。
|
||||
this.filePath = filePath;
|
||||
allProviders.Add(new(this));
|
||||
saveAction = Throttler.Throttle(Save, TimeSpan.FromMilliseconds(500), leading: false, trailing: true);
|
||||
saveWorker = new(Save, 500, RateLimitMode.WaitUnillNoNewInvoke);
|
||||
InitJson();
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ public class JsonConfigProvider : IConfigProvider {
|
||||
|
||||
// ===================================== 保存 =====================================
|
||||
|
||||
private readonly RateLimitedAction saveAction;
|
||||
private readonly RateLimitedWorker saveWorker;
|
||||
private bool isDirty = false;
|
||||
public void MakeDirty() {
|
||||
isDirty = true;
|
||||
saveAction.Invoke();
|
||||
saveWorker.Start();
|
||||
}
|
||||
public void Save() {
|
||||
if (!isDirty) return;
|
||||
|
||||
Reference in new issue
Block a user