ICommunicationObject.Open 方法

定义

使通信对象从已创建状态转换到已打开状态。Causes a communication object to transition from the created state into the opened state.

重载

Open()

使通信对象从已创建状态转换到已打开状态。Causes a communication object to transition from the created state into the opened state.

Open(TimeSpan)

使通信对象在指定时间间隔内从已创建状态转换到已打开状态。Causes a communication object to transition from the created state into the opened state within a specified interval of time.

注解

提供了有显式超时和没有显式超时两个版本。Versions with and without an explicit timeout are provided.

Open()

使通信对象从已创建状态转换到已打开状态。Causes a communication object to transition from the created state into the opened state.

public:
 void Open();
public void Open ();
abstract member Open : unit -> unit
Public Sub Open ()

例外

ICommunicationObject 无法打开并且已进入 Faulted 状态。The ICommunicationObject was unable to be opened and has entered the Faulted state.

ICommunicationObject(已经进入 Opened 状态)能够进入 Faulted 状态之前所经过的默认打开超时。The default open timeout elapsed before the ICommunicationObject was able to enter the Opened state and has entered the Faulted state.

注解

实例化 ICommunicationObject 时,它将以 Created 状态启动。When an ICommunicationObject is instantiated, it begins in the Created state. 在处于 Created 状态时,可以配置此对象(例如,可以设置属性或注册事件),但仍不能用此对象发送或接收消息。In the Created state, the object can be configured (for example, properties can be set, or events can be registered), but it is not yet usable to send or receive messages. Open 方法导致 ICommunicationObject 进入 Opening 状态,在该状态下,该操作会一直保留,直到打开操作成功、打开操作超时或失败以及对象出现故障或 ICommunicationObject 中止。The Open method causes an ICommunicationObject to enter into the Opening state where it remains until the open operation succeeds, the open operation times out or fails and the object becomes faulted, or the ICommunicationObject is aborted.

Opened 状态下,ICommunicationObject 可用(例如,可以接收消息),但它不再可配置。In the Opened state, the ICommunicationObject is usable (for example, messages can be received), but it is no longer configurable.

还有一个打开方法的异步版本,该方法可通过调用 BeginOpen 来启动并通过调用 EndOpen(IAsyncResult) 来完成。There is also an asynchronous version of the open method that is initiated by calling BeginOpen and completed by calling EndOpen(IAsyncResult).

Open(TimeSpan)

使通信对象在指定时间间隔内从已创建状态转换到已打开状态。Causes a communication object to transition from the created state into the opened state within a specified interval of time.

public:
 void Open(TimeSpan timeout);
public void Open (TimeSpan timeout);
abstract member Open : TimeSpan -> unit
Public Sub Open (timeout As TimeSpan)

参数

timeout
TimeSpan

TimeSpan,指定在超时前必须完成发送操作的时间。The TimeSpan that specifies how long the send operation has to complete before timing out.

例外

ICommunicationObject 无法打开并且已进入 Faulted 状态。The ICommunicationObject was unable to be opened and has entered the Faulted state.

ICommunicationObject(已经进入 Opened 状态)能够进入 Faulted 状态之前所经过的指定超时。The specified timeout elapsed before the ICommunicationObject was able to enter the Opened state and has entered the Faulted state.

注解

实例化 ICommunicationObject 时,它将以 Created 状态启动。When an ICommunicationObject is instantiated, it begins in the Created state. 在处于 Created 状态时,可以配置此对象(例如,可以设置属性或注册事件),但仍不能用此对象发送或接收消息。In the Created state, the object can be configured (for example, properties can be set, or events can be registered), but it is not yet usable to send or receive messages. Open 方法导致 ICommunicationObject 进入 Opening 状态,在该状态下,该操作会一直保留,直到打开操作成功、打开操作超时或失败以及对象出现故障或 ICommunicationObject 中止。The Open method causes an ICommunicationObject to enter into the Opening state where it remains until the open operation succeeds, the open operation times out or fails and the object becomes faulted, or the ICommunicationObject is aborted.

Opened 状态下,ICommunicationObject 可用(例如,可以接收消息),但它不再可配置。In the Opened state, the ICommunicationObject is usable (for example, messages can be received), but it is no longer configurable.

还有一个打开方法的异步版本,该方法可通过调用 BeginOpen 来启动并通过调用 EndOpen(IAsyncResult) 来完成。There is also an asynchronous version of the open method that is initiated by calling BeginOpen and completed by calling EndOpen(IAsyncResult).

实施者说明

如果超过指定的 timeout,操作必须引发 TimeoutExceptionThe operation must throw a TimeoutException if the specified timeout is exceeded.

适用于