开发者

call to WCF from multiple threads returns properties with null value sometimes

开发者 https://www.devze.com 2023-02-13 14:30 出处:网络
I call a WCF service from multiple threads at the same time, but the response comes empty. If i have like 10 threads working in parallel calling the service, only 1 returs the data, the rest of them r

I call a WCF service from multiple threads at the same time, but the response comes empty. If i have like 10 threads working in parallel calling the service, only 1 returs the data, the rest of them return all properties with null value. The service is consumed by another project in the same solution in VS. The service refference is obtained by discovery(so the service is not hosted in IIS).

Why do y开发者_开发问答ou think I get this behaviour? If I only allow one thread at a time with:

 myList.AsParallel().WithDegreeOfParallelism(1).ForAll(x => Worker(x));

all is fine, but I need at least 5 to speed things up. Worker method calls the WCF service.

 public void Worker(object cui)
    {

        MyData mf = null;
        mf = (new AnalyseService.AnalyseServiceClient()).GetDataFromWCFService((string)cui, true);
    }

On the server the response is always correct, but when it reaches the client it may have it's properties equl null


It turned out that VS was having some problems with this.

0

精彩评论

暂无评论...
验证码 换一张
取 消