ServiceThrottlingBehavior.MaxConcurrentInstances Propriedade

Definição

Obtém ou define um valor que especifica o número máximo de objetos InstanceContext no serviço que podem ser executados ao mesmo tempo.Gets or sets a value that specifies the maximum number of InstanceContext objects in the service that can execute at one time.

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

Valor da propriedade

O número máximo de objetos InstanceContext no serviço simultaneamente.The maximum number of InstanceContext objects in the service at one time. O padrão é a soma do valor de MaxConcurrentSessions e o valor de. MaxConcurrentCallsThe default is the sum of the value of MaxConcurrentSessions and the value of MaxConcurrentCalls.

Exemplos

O exemplo de código a seguir mostra o ServiceThrottlingBehavior uso de de um arquivo de configuração de aplicativo MaxConcurrentCalls que MaxConcurrentInstances define as MaxConcurrentSessionsPropriedades e como 1 como um exemplo.The following code example shows the use of ServiceThrottlingBehavior from an application configuration file that sets the MaxConcurrentSessions, MaxConcurrentCalls and MaxConcurrentInstances properties to 1 as an example. A experiência do mundo real determina quais são as configurações ideais para qualquer aplicativo específico.Real-world experience determines what the optimal settings are for any particular application.

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

Comentários

A MaxConcurrentInstances propriedade especifica o número máximo de InstanceContext objetos no serviço.The MaxConcurrentInstances property specifies the maximum number of InstanceContext objects in the service. É importante ter em mente a relação entre a MaxConcurrentInstances Propriedade e a InstanceContextMode propriedade.It is important to keep in mind the relationship between the MaxConcurrentInstances property and the InstanceContextMode property. Se InstanceContextMode forPerSession, o valor resultante será o número total de sessões.If InstanceContextMode is PerSession, the resulting value is the total number of sessions. Se InstanceContextMode forPerCall, o valor resultante será o número de chamadas simultâneas.If InstanceContextMode is PerCall, the resulting value is the number of concurrent calls. Se uma mensagem chegar enquanto o número máximo de InstanceContext objetos já existir, a mensagem será mantida até que InstanceContext um objeto seja fechado.If a message arrives while the maximum number of InstanceContext objects already exist, the message is held until an InstanceContext object closes.

Você também pode definir os valores desse atributo usando o <> elemento perthrottling em um arquivo de configuração de aplicativo.You can also set the values of this attribute by using the <serviceThrottling> element in an application configuration file.

Aplica-se a