ServiceThrottlingBehavior.MaxConcurrentInstances Eigenschap

Definitie

Hiermee wordt een waarde opgehaald of ingesteld waarmee het maximum aantal InstanceContext objecten in de service wordt opgegeven dat tegelijk kan worden uitgevoerd.

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

Waarde van eigenschap

Het maximum aantal InstanceContext objecten in de service tegelijk. De standaardwaarde is de som van de waarde van MaxConcurrentSessions en de waarde van MaxConcurrentCalls.

Voorbeelden

In het volgende codevoorbeeld ziet u het gebruik van ServiceThrottlingBehavior een toepassingsconfiguratiebestand waarmee de MaxConcurrentSessionsen MaxConcurrentInstancesMaxConcurrentCalls eigenschappen worden ingesteld op 1 als voorbeeld. Ervaring in de praktijk bepaalt wat de optimale instellingen zijn voor een bepaalde toepassing.

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

Opmerkingen

De MaxConcurrentInstances eigenschap geeft het maximum aantal InstanceContext objecten in de service op. Het is belangrijk om rekening te houden met de relatie tussen de MaxConcurrentInstances eigenschap en de InstanceContextMode eigenschap. Als InstanceContextMode dat het is PerSession, is de resulterende waarde het totale aantal sessies. Als InstanceContextMode dat het is PerCall, is de resulterende waarde het aantal gelijktijdige aanroepen. Als er een bericht binnenkomt terwijl het maximum aantal InstanceContext objecten al bestaat, wordt het bericht bewaard totdat een InstanceContext object wordt gesloten.

U kunt ook de waarden van dit kenmerk instellen met behulp van het <servicebeperkingselement> in een toepassingsconfiguratiebestand.

Van toepassing op