public enum class CommunicationState
public enum CommunicationState
type CommunicationState =
Public Enum CommunicationState
|Closed Closed Closed Closed||4||
指示通信对象已关闭，且不再可用。Indicates that the communication object has been closed and is no longer usable.
|Closing Closing Closing Closing||3|
|Created Created Created Created||0||
指示通信对象已实例化且可配置，但尚未打开或无法使用。Indicates that the communication object has been instantiated and is configurable, but not yet open or ready for use.
|Faulted Faulted Faulted Faulted||5||
指示通信对象发生错误，无法恢复且不再可用。Indicates that the communication object has encountered an error or fault from which it cannot recover and from which it is no longer usable.
|Opened Opened Opened Opened||2||
指示通信对象目前已打开，且随时可供使用。Indicates that the communication object is now open and ready to be used.
|Opening Opening Opening Opening||1|
此枚举定义对系统中所有通信对象（包括通道、侦听器、工厂、调度程序和服务主机）都有效的状态。This enumeration defines the states that are valid for all communication objects in the system, including channels, listeners, factories, dispatchers, and service hosts.
用于管理这些状态间转换的方法以及可与这些状态关联的事件，都是在 ICommunicationObject 界面中进行定义。The methods that manage transitions between these states and the events that can be associated with them are defined in the ICommunicationObject interface. 对象的状态可以通过 State 属性来获取。The state of an object can be obtained using the State property.
通信对象可能会处于四个主状态以及两个暂时状态。There are four main states and two transient states that a communication object can occupy. 主状态有：The main states are:
当在这些主状态之间转换时，通信对象可能会处于下列两个暂时状态：The two transitory states that a communication object can occupy when transitioning between these main states are:
可以将通信对象配置为 "已创建" 状态。The communication object can be configured in the Created state. 例如，可以更改其属性，可以注册其事件。For example, its properties can be changed, and its events can be registered. 在此状态下，不能进行输入或输出。No input or output can occur in this state. 例如，不能在此状态下从通道发送或接收消息。So messages, for example, cannot be sent or received from a channel in this state.
打开的是在调用 Open 方法时通信对象输入的临时状态。The Opening is a temporary state that the communication object enters when the Open method is invoked. 除非对派生类另有说明，否则无法配置处于打开状态的对象。Unless otherwise noted on derived classes, objects in the opening state cannot be configured. 只能从创建的状态中输入此转换状态。This transition state can only be entered from the Created state.
当打开进程完成时，对象转换为打开的状态。Objects transition to the Opened state when the open process completes. 此转换到已打开状态仅从打开状态有效。This transition to the Opened state is only valid from the Opening state. 除非对派生类另有说明，否则目前无法配置对象。Unless otherwise noted on derived classes, the configuration of the object is now disabled. 此时，对象完全可用于消息传送。At this point, the object is fully usable for message transfers.
关闭是一种临时状态，当调用 Close 方法以便正常关闭或中止对象时，对象将进入该状态。The Closing is a temporary state that the object enters when the Close method is invoked for a graceful shutdown or the object is aborted. 此时，对象会由可用变为不可用。At this point, the object becomes (if not already) unusable. 此转换从 "已关闭" 状态以外的任何状态有效。This transition is valid from any state except the Closed state.
关闭状态等效于正在释放，并且仍可以检查对象的配置。The Closed state is equivalent to being disposed and the configuration of the object can still be inspected.
错误状态用于指示对象已转换为不能再使用它的状态。The Faulted state is used to indicate that the object has transitioned to a state where it can no longer be used. 有两种主要情况可能会发生此状况：There are two primary scenarios where this can happen:
如果基于会话的通道检测到无法恢复的错误，则会转换到出错状态。If a session-based channel detects an error that it cannot recover from, it transitions to the faulted state. 例如，在发生协议错误（即在无效时间收到协议消息）或远程终结点中止会话时，可能会发生此状况。This can happen for instance if there is a protocol error (that is, it receives a protocol message at an invalid time) or if the remote endpoint aborts the session.
处于错误状态的对象未关闭并且可能正在保存资源。An object in the Faulted state is not closed and may be holding resources. 应该使用 Abort 方法来关闭出错的对象。The Abort method should be used to close an object that has faulted. 如果对出错状态下的对象调用 Close，则会引发 @no__t，因为不能正常关闭对象。If Close is called on an object in the Faulted state, a CommunicationObjectFaultedException is thrown because the object cannot be gracefully closed.