繁体   English   中英

WCF 服务需要异步调用

[英]WCF service need to call Asynchronous

我正在尝试使用客户端异步调用 WCF 服务。 对于参考我选择生成异步操作,问题是如果我调用相同的服务 10 次,一旦所有 100 个服务完成,控制就转到完成的委托,并且作为响应,它为所有 100 个服务提供相同的时间。 例如 - 像这样我无法获得每个呼叫的响应时间,因为所有呼叫响应都在同一时间返回。 这是我调用服务的代码

wsClient.GetCustomerGeoCodeCompleted += (sender, args) => client_GetCustomerGeoCodeCompleted(sender, args);
wsClient.GetCustomerGeoCodeAsync(GetCustomerGeoCodeRequest, lintRequestCount.ToString());

这是我的代表

public void client_GetCustomerGeoCodeCompleted(object sender, wsIntegrationService.GetCustomerGeoCodeCompletedEventArgs e)
{
    try
    {
        if (e.Error == null)
        {
           // lintResponseCount += 1;
            WriteLog(strResponseLogpath, e.UserState + " - SUCCESS -  Get Customer Geo - " + "Record Received" + e.Result.Count().ToString()) + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss:FFF"));

        }
        else
        {
            WriteLog(logpath, "ERROR -> : Get Customer Geo " + e.Error.Message.ToString());
        }
    }
    catch (Exception ex)
    {
        WriteLog(logpath, "ERROR -> : Get Customer Geo " + ex.Message.ToString());
    }
}

任何建议我如何在该请求的服务呼叫完成后立即休息。

我在通话中添加了等待并根据需要工作

await Task.Run(() => wsClient.GetSalesOrderV1Async(GetSalesOrderRequest, lintRequestCount.ToString() +"-"+  dr["TenantCode"].ToString()));

让我知道是否有其他方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM