简体   繁体   English

WCF 服务需要异步调用

[英]WCF service need to call Asynchronous

i am trying to call WCF service asynchronously using client.我正在尝试使用客户端异步调用 WCF 服务。 for that in reference i selected generate asynchronous operation, problem is if i call same service 10 time, control goes to completed delegate once all 100 service finish and in response its give same time for all 100 service.对于参考我选择生成异步操作,问题是如果我调用相同的服务 10 次,一旦所有 100 个服务完成,控制就转到完成的委托,并且作为响应,它为所有 100 个服务提供相同的时间。 for ex - like this i not able to get response time of each call as all call response return on same time.例如 - 像这样我无法获得每个呼叫的响应时间,因为所有呼叫响应都在同一时间返回。 this is my code for call the service这是我调用服务的代码

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

this one is my delegate这是我的代表

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());
    }
}

any suggestion how i can get repose as soon as service call finish for that request.任何建议我如何在该请求的服务呼叫完成后立即休息。

i added awaits in call and work as needed我在通话中添加了等待并根据需要工作

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

let me know if any other approach让我知道是否有其他方法

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

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