feat: 优化初始化缓存及控件功能

This commit is contained in:
cyf
2026-08-14 20:33:43 +08:00
parent 222ae3c08a
commit f665688d0b
27 changed files with 505 additions and 106 deletions
+27 -1
View File
@@ -211,7 +211,7 @@ namespace Lskj.PubModuleDetail
Dictionary<object, Hashtable> dataCaches =
Model != null ? Model.DataCaches : null;
if (dataCaches == null)
if (dataCaches == null || !AreDataCacheTasksCompleted(dataCaches))
{
return;
}
@@ -262,5 +262,31 @@ namespace Lskj.PubModuleDetail
}
}
}
/// <summary>
/// 并行初始化仍在运行时不能清空缓存字典,后台任务还会读取或追加其中的数据。
/// </summary>
private static bool AreDataCacheTasksCompleted(Dictionary<object, Hashtable> dataCaches)
{
try
{
foreach (Hashtable cacheValues in dataCaches.Values)
{
foreach (object value in cacheValues.Values)
{
Task task = value as Task;
if (task != null && !task.IsCompleted)
{
return false;
}
}
}
return true;
}
catch (InvalidOperationException)
{
return false;
}
}
}
}