Share via


ServiceThrottle.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 * 電腦上的處理器數目。

範例

下列程式碼範例將示範參考應用程式組態檔內 ServiceThrottle 的典型 ServiceThrottlingBehavior 用法。 在此情況下,所指定的值一次最多會建立一個訊息處理 (從一個連線到一個 InstanceContext)。 實際用法必須取決於經驗。

<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

注意

每當超過這個屬性值時,就會寫入至追蹤。

適用於