[英]How to get/set the number of threads WCF uses to handle requests in parallel?
如何获取并设置WCF服务器线程池中允许并行处理传入请求的线程数?
我正在使用WebHttpBinding。
您可以通过ServiceThrottlingBehavior
类获取它们,默认值如下
.NET 3.0 / 3.5
.NET 4.0以上
您最感兴趣的是MaxConcurrentInstances
,因为这会消耗线程。 通常,如果您在哪里配置它,可以在app.config文件中进行设置
<configuration>
<appSettings>
<!-- use appSetting to configure base address provided by host -->
<add key="baseAddress" value="http://localhost:8080/ServiceMetadata" />
</appSettings>
<system.serviceModel>
<services>
<service
name="Microsoft.WCF.Documentation.SampleService"
behaviorConfiguration="Throttled" >
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/SampleService"/>
</baseAddresses>
</host>
<endpoint
address=""
binding="wsHttpBinding"
contract="Microsoft.WCF.Documentation.ISampleService"
/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Throttled">
<serviceThrottling
maxConcurrentCalls="1"
maxConcurrentSessions="1"
maxConcurrentInstances="1"
/>
<serviceMetadata
httpGetEnabled="true"
httpGetUrl=""
/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
通过代码查找要困难得多(我不知道怎么做,我通常只使用配置文件)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.