提交 509f22be 编写于 作者: T tanghai

修复DBQueryTask DBQueryBatchTask中的阻塞调用

上级 379d65ac
......@@ -39,7 +39,8 @@ namespace ETModel
ComponentWithId component = dbCacheComponent.GetFromCache(this.CollectionName, id);
if (component == null)
{
component = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == id).Result.FirstOrDefaultAsync();
IAsyncCursor<ComponentWithId> cursor = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == id);
component = await cursor.FirstOrDefaultAsync();
}
if (component == null)
......
......@@ -34,7 +34,8 @@ namespace ETModel
try
{
// 执行查询数据库任务
component = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == this.Id).Result.FirstOrDefaultAsync();
IAsyncCursor<ComponentWithId> cursor = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == this.Id);
component = await cursor.FirstOrDefaultAsync();
this.Tcs.SetResult(component);
}
catch (Exception e)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册