次の方法で共有


ServiceThrottle.MaxConcurrentSessions プロパティ

定義

ServiceHost オブジェクトが一度に受け入れることができるセッションの最大数を指定する値を取得または設定します。

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

プロパティ値

サービス ホストが受け入れるセッションの最大数。 既定値は 100 * コンピューター内のプロセッサの数です。

次のコード例は、アプリケーション構成ファイル内のServiceThrottlingBehaviorを参照することによって、ServiceThrottleの一般的な使用方法を示しています。 この場合、指定された値は、1 つの接続から 1 つの InstanceContextに一度に 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>

注釈

MaxConcurrentSessions プロパティは、ServiceHostが受け入れることができるチャネルの最大数を指定します。 各リスナー オブジェクトには、WCF がチャネルを受け入れてメッセージの処理を開始するまで、 MaxConcurrentSessions の値に対してカウントされない保留中のチャネルを 1 つ持つことができます。 このプロパティは、セッションを利用するシナリオで最も役立ちます。

トレースは、このプロパティの値を超えるたびに書き込まれます。 最初のトレースは警告として書き込まれます。

セッションの詳細については、「セッションの 使用」を参照してください。

通常、このプロパティは ServiceThrottlingBehavior.MaxConcurrentSessions プロパティを使用して設定されます。

適用対象