Вы можете получить доступ к свойству LeaseTimeout
через TcpTransportBindingElement
, через свойство ConnectionPoolSettings
:
TcpTransportBindingElement tcpBE = new TcpTransportBindingElement();
tcpBE.ConnectionPoolSettings.LeaseTimeout = TimeSpan.FromSeconds(1);
Если у вас есть объект NetTcpBinding
, вам необходимо сначала преобразовать его в CustomBinding
, а затем получить доступ к элементу привязки. Пример ниже показывает один из способов сделать это.
NetTcpBinding myOriginalBinding = CreateBinding();
CustomBinding newBinding = new CustomBinding(myOriginalBinding);
TcpTransportBindingElement tcpBE = newBinding.Elements.Find<TcpTransportBindingElement>();
tcpBE.ConnectionPoolSettings.LeaseTimeout = TimeSpan.FromSeconds(1);