要么await,要么wait

查询条件总是不管用,最后发现忘了写wait,服了。

写法1:

public override Expression<Func<AcctMubanZhuan, bool>> buildQueryWhere()
{   //查询条件
    Expression<Func<AcctMubanZhuan, bool>> result = p => true;
    iPublicX.getPostedDataAsync<ParamQuery>(Request).ContinueWith((task) =>
    {
        if (task.Status == TaskStatus.RanToCompletion) paramQuery = task.Result;
        if (paramQuery != null)
        {
            if (!string.IsNullOrEmpty(paramQuery.sType)) result = result.And<AcctMubanZhuan>(p => p.sType.StartsWith(paramQuery.sType));
        }
    }).Wait();
    return result;
}

 

写法2:整个函数写成异步sync

await iPublicX.getPostedDataAsync<queryLedgerParam>(Request).ContinueWith(task =>
{
    param = task.Result;
});

 

posted @ 2026-07-02 15:18  海宏软件  阅读(3)  评论(0)    收藏  举报