feat: 优化初始化缓存及控件功能
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user