ServiceHostBase.OnClose(TimeSpan) 方法
定义
关闭所承载服务,包括它们的通道调度程序以及相关的实例上下文和侦听器。Closes down the hosted service, including their channel dispatchers and associated instance contexts and listeners.
protected:
override void OnClose(TimeSpan timeout);
protected override void OnClose (TimeSpan timeout);
override this.OnClose : TimeSpan -> unit
Protected Overrides Sub OnClose (timeout As TimeSpan)
参数
- timeout
- TimeSpan
TimeSpan,指定在超时前必须完成关闭操作的时间。The TimeSpan that specifies how long the on-close operation has to complete before timing out.
注解
调用 OnClose(TimeSpan) 会执行以下操作:Calling OnClose(TimeSpan) does the following:
关闭到的所有输入 ChannelDispatcher ,这也会关闭其关联的 IChannelListener 实例。Closes all input to ChannelDispatcher, which also closes their associated IChannelListener instances. 这会阻止接受任何新通道。This stops any new channels from being accepting.
CloseInput对所有 InstanceContext 对象调用,这意味着它们将停止接受新消息。Calls CloseInput on all InstanceContext objects, which mean they stop accepting new messages.
等待所有 InstanceContext 对象关闭,这会在其关联通道完成发送所有挂起消息时发生。Waits for all InstanceContext objects to close down, which happens when their associated channels finish sending all pending messages.
关闭 ChannelDispatcher 与宿主关联的对象。Closes the ChannelDispatcher objects associated with the host.