Skip to content

Commit

Permalink
添加实体过滤模块时,稍微等一下,确保添加成功,而又规避了可能的死循环
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Nov 6, 2023
1 parent c902e38 commit 63b0afd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion XCode/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private Task<Int32> DoAction(Func<Task<Int32>> func, Boolean? isnew)
private Boolean enableValid = true;

/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
/// <remarks>建议重写者调用基类的实现,因为基类自动填充雪花Id并验证字符串字段是否超长。</remarks>
/// <remarks>建议重写者调用基类的实现,因为基类自动生成雪花Id、填充创建更新信息以及验证字符串字段是否超长。</remarks>
/// <param name="isNew">是否新数据</param>
public override void Valid(Boolean isNew)
{
Expand Down
4 changes: 3 additions & 1 deletion XCode/Entity/IEntityModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public class EntityModules : IEnumerable<IEntityModule>
public virtual void Add(IEntityModule module)
{
// 异步添加实体模块,避免死锁。实体类一般在静态构造函数里面添加模块,如果这里同步初始化会非常危险
ThreadPool.UnsafeQueueUserWorkItem(s => AddAsync(s as IEntityModule), module);
//ThreadPool.UnsafeQueueUserWorkItem(s => AddAsync(s as IEntityModule), module);
var task = Task.Run(() => AddAsync(module));
task.Wait(1_000);
}

/// <summary>添加实体模块</summary>
Expand Down

0 comments on commit 63b0afd

Please sign in to comment.