根据MSDN,如果WCF服务的MaxPendingAccepts设置为0,WCF将为我们配置值。
这是什么意思?它是动态变化的吗?那背后的算法是什么?
答案 0 :(得分:2)
我看了System.ServiceModel.Channels.HttpTransportBindingElement
的源代码。该类的默认构造函数具有以下代码行:
this.maxPendingAccepts = HttpTransportDefaults.DefaultMaxPendingAccepts;
查看HttpTransportsDefault
会显示以下代码:
// We use 0 as the default value of the MaxPendingAccepts property on HttpTransportBindingElement. In 4.5 we always
// use 10 under the hood if the default value is picked. In future releases, we could adjust the underlying default
// value when we have the dynamic expending pattern of BeginGetContext call implemented and the heap fragmentation issue
// from NCL layer solved.
const int PendingAcceptsConstant = 10;
internal const int DefaultMaxPendingAccepts = 0;
internal const int MaxPendingAcceptsUpperLimit = 100000;
internal static int GetEffectiveMaxPendingAccepts(int maxPendingAccepts)
{
return maxPendingAccepts == HttpTransportDefaults.DefaultMaxPendingAccepts ?
PendingAcceptsConstant :
maxPendingAccepts;
}
所以看起来如果你使用0(默认值),你实际上会得到10,而你的上限是100,000。
因此,实质上如果将值设置为0(或者甚至不设置全部,这将使其默认为0),实际值将为10.