Editare

Partajați prin


ServiceThrottle.MaxConcurrentInstances Property

Definition

Gets or sets the maximum number of service objects 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

Property Value

The maximum number of InstanceContext objects in the service at one time. The default is Maximum Concurrent Calls + Maximum Concurrent Sessions.

Examples

The following code example shows the typical use of the ServiceThrottle by referencing the ServiceThrottlingBehavior in an application configuration file. In this case, the values that are specified establish, at most, one message processing at one time from one connection to one InstanceContext. Real-world usage must be determined through experience.

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

Remarks

The MaxConcurrentInstances property specifies the maximum number of InstanceContext objects in the service. It is important to keep in mind the relationship between the MaxConcurrentInstances property and the InstanceContextMode property. If InstanceContextMode is PerSession the resulting value is the total number of sessions. If InstanceContextMode is PerCall, the resulting value is the number of concurrent calls. If a message arrives while the maximum number of InstanceContext objects already exist, the message is held until an InstanceContext object closes.

Note

A trace is written every time the value of this property is exceeded. The first trace is written as a warning.

Applies to