ICommunicationObject.BeginClose 方法
定义
开始一个异步操作以关闭通信对象。Begins an asynchronous operation to close a communication object.
重载
| BeginClose(AsyncCallback, Object) |
开始一个异步操作以关闭通信对象。Begins an asynchronous operation to close a communication object. |
| BeginClose(TimeSpan, AsyncCallback, Object) |
开始一个异步操作以在指定超时内关闭通信对象。Begins an asynchronous operation to close a communication object with a specified timeout. |
注解
此方法导致 ICommunicationObject 从状态正常转换 Opened 到 Closed 状态。This method causes an ICommunicationObject to gracefully transition from the Opened state to the Closed state.
提供了有显式超时和没有显式超时两个版本。Versions with and without an explicit timeout are provided.
BeginClose(AsyncCallback, Object)
开始一个异步操作以关闭通信对象。Begins an asynchronous operation to close a communication object.
public:
IAsyncResult ^ BeginClose(AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginClose (AsyncCallback callback, object state);
abstract member BeginClose : AsyncCallback * obj -> IAsyncResult
Public Function BeginClose (callback As AsyncCallback, state As Object) As IAsyncResult
参数
- callback
- AsyncCallback
接收异步关闭操作完成通知的 AsyncCallback 委托。The AsyncCallback delegate that receives notification of the completion of the asynchronous close operation.
- state
- Object
一个由应用程序指定的对象,它包含与异步关闭操作相关联的状态信息。An object, specified by the application, that contains state information associated with the asynchronous close operation.
返回
引用异步关闭操作的 IAsyncResult。The IAsyncResult that references the asynchronous close operation.
例外
对处于 BeginClose(AsyncCallback, Object) 状态的对象调用了 Faulted。BeginClose(AsyncCallback, Object) was called on an object in the Faulted state.
在 ICommunicationObject 能够正常关闭之前所经过的默认超时。The default timeout elapsed before the ICommunicationObject was able to close gracefully.
注解
此方法导致 ICommunicationObject 从状态正常转换为状态,而不是状态 Opened Closed 。This method causes an ICommunicationObject to gracefully transition from any state, other than the Opened state to the Closed state. 使用 BeginClose 方法,可在返回之前完成所有未完成的工作。The BeginClose method allows any unfinished work to be completed before returning. 例如,完成所有缓冲的消息的发送)。For example, finish sending any buffered messages).
适用于
BeginClose(TimeSpan, AsyncCallback, Object)
开始一个异步操作以在指定超时内关闭通信对象。Begins an asynchronous operation to close a communication object with a specified timeout.
public:
IAsyncResult ^ BeginClose(TimeSpan timeout, AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state);
abstract member BeginClose : TimeSpan * AsyncCallback * obj -> IAsyncResult
Public Function BeginClose (timeout As TimeSpan, callback As AsyncCallback, state As Object) As IAsyncResult
参数
- timeout
- TimeSpan
TimeSpan,指定在超时前必须完成发送操作的时间。The TimeSpan that specifies how long the send operation has to complete before timing out.
- callback
- AsyncCallback
接收异步关闭操作完成通知的 AsyncCallback 委托。The AsyncCallback delegate that receives notification of the completion of the asynchronous close operation.
- state
- Object
一个由应用程序指定的对象,它包含与异步关闭操作相关联的状态信息。An object, specified by the application, that contains state information associated with the asynchronous close operation.
返回
引用异步关闭操作的 IAsyncResult。The IAsyncResult that references the asynchronous close operation.
例外
对处于 BeginClose(TimeSpan, AsyncCallback, Object) 状态的对象调用了 Faulted。BeginClose(TimeSpan, AsyncCallback, Object) was called on an object in the Faulted state.
在 ICommunicationObject 能够正常关闭之前所经过的指定超时。The specified timeout elapsed before the ICommunicationObject was able to close gracefully.
注解
此方法会导致 ICommunicationObject Opened Closed 在指定时间间隔内从任何状态正常转换为状态,而不是状态。This method causes an ICommunicationObject to gracefully transition from any state, other than the Opened state to the Closed state with in a specified interval of time. 使用 BeginClose 方法,可在返回之前完成所有未完成的工作。The BeginClose method allows any unfinished work to be completed before returning. 例如,完成所有缓冲的消息的发送)。For example, finish sending any buffered messages).