日期:2014-05-17 浏览次数:20929 次
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
using System;
using System.Collections.ObjectModel;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
/// <summary>
/// 吞吐量配置实类
/// </summary>
public class ServiceThrottlingAttribute : Attribute, IServiceBehavior
{
private ServiceThrottlingBehavior Throttling;
/// <summary>
/// 实例化 ServiceThrottlingAttribute 新的实例
/// </summary>
public ServiceThrottlingAttribute()
: this(64, System.Int32.MaxValue, 10)
{
}
/// <summary>
/// 实例化 ServiceThrottlingAttribute 新的实例
/// </summary>
/// <param name="maxConcurrentCalls">指定整个 System.ServiceModel.ServiceHost 中正在处理的最多消息数</param>
/// <param name="maxConcurrentInstances">指定服务中可以一次执行的最多 System.ServiceModel.InstanceContext 对象数</param>
/// <param name="maxConcurrentSessions">指定 System.ServiceModel.ServiceHost 对象可一次接受的最多会话数的值</param>
public ServiceThrottlingAttribute(int maxConcurrentCalls, int maxConcurrentInstances, int maxConcurrentSessions)
{
this.Throttling = new ServiceThrottlingBehavior();
this.MaxConcurrentCalls = maxConcurrentCalls;
this.MaxConcurrentInstances = maxConcurrentInstances;
this.MaxConcurrentSessions = maxConcurrentSessions;
}
/// <summary>
/// 获取或设置一个值,该值指定整个 System.ServiceModel.ServiceHost 中正在处理的最多消息数(默认