WCF服务调用第一次没有并行运行 [英] WCF service call didn't run parallel on first time

查看:63
本文介绍了WCF服务调用第一次没有并行运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wcf服务调用,它是从c#应用程序调用的。我使用线程调用了wcf服务并行。在这里,我发现第二个线程的服务调用阻塞,直到来自第一个线程的服务调用。在此服务之后,来自其他线程的呼叫被称为并行。







服务电话S1。

线程T1,T2,T3,T4



首先我从T1调用S1,然后在完成此操作之前从T2调用s1。但来自T2的呼叫被T1阻塞,T 2仅在T1完成时才开始。然后我从T3调用S1,然后从T3开始调用我开始T4,但这些调用是并行执行的。



这里只有第一次调用wcf服务才有什么问题。取决于任何配置?我怎么解决呢?



提前谢谢。

I have a wcf service call, which is calling from c# application. I made a call to wcf service parallel using thread. Here i found that service call from second thread is blocking until service call from fist thread. After this service call from other thread are called parallel.

ie

Service call S1.
Thread T1, T2, T3, T4

First i called S1 from T1, before completing this i called s1 from T2. but call from T2 is blocking by T1, T 2 start only when once T1 done. Then i called S1 from T3 before completing call from T3 i start T4, but these calls are executing parallel.

What is the issue here only for first call to wcf service. Is depend on any configuration? How can i resolve it?

Thanks in advance.

推荐答案

我从
最佳实践:在共享时始终明确打开WCF客户端代理 - Wenlong Dong&博客 - 站点主页 - MSDN博客



这是因为代理初始化。因此,在初始化代理之前,它将阻止所有类似的调用。一旦代理初始化,所有类似的调用将并行运行。



所以这里我们总是在你打电话之前明确打开WCF客户端代理
I got the solution from
Best Practice: Always open WCF client proxy explicitly when it is shared - Wenlong Dong's Blog - Site Home - MSDN Blogs

This is because of Proxy initialization. So until initialize proxy it will block all similar call. Once proxy initialize, all the similar call will be run parallel.

So here we always open WCF client proxy explicitly before you are making any calls


这篇关于WCF服务调用第一次没有并行运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆