ServiceThrottlingBehavior.MaxConcurrentCalls 屬性

定義

取得或設定值,這個值指定 ServiceHost 上主動處理的訊息數目上限。

public:
 property int MaxConcurrentCalls { int get(); void set(int value); };
public int MaxConcurrentCalls { get; set; }
member this.MaxConcurrentCalls : int with get, set
Public Property MaxConcurrentCalls As Integer

屬性值

在服務內作用中訊息的上限。 預設為 16 乘以處理器計數。

範例

下列程式碼範例會示範如何使用應用程式組態檔的 ServiceThrottlingBehavior,將 MaxConcurrentSessionsMaxConcurrentCallsMaxConcurrentInstances 屬性設定為 1。 至於特定應用程式的最佳設定,則需要透過實際經驗來判斷。

<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>

備註

MaxConcurrentCalls 屬性會指定 ServiceHost 物件上主動處理的訊息數目上限。 每個通道可以有一個擱置的訊息,直到 Windows Communication Foundation (WCF) 開始處理為止,才會計入 的值 MaxConcurrentCalls

您也可以在應用程式組態檔中使用< serviceThrottling >元素來設定此屬性的值。

警告

MaxConcurrentCalls 應該設定為小於佇列案例中的 SQL 連線集區大小。

適用於