OperationContext.OperationCompleted 事件

定義

發生於作業已經完成時。Occurs when the operation has completed.

public:
 event EventHandler ^ OperationCompleted;
public event EventHandler OperationCompleted;
member this.OperationCompleted : EventHandler 
Public Custom Event OperationCompleted As EventHandler 
Public Event OperationCompleted As EventHandler 

事件類型

EventHandler

備註

OperationCompleted如果您將設定為,請使用事件來處置參數或傳回值 OperationBehaviorAttribute.AutoDisposeParameters falseUse the OperationCompleted event to dispose parameters or a return value if you set OperationBehaviorAttribute.AutoDisposeParameters to false. 一般來說,您會將設定 OperationBehaviorAttribute.AutoDisposeParameters 為, false 以防止 WCF 呼叫 IDisposable.Dispose 參數和傳回值物件。Normally you set OperationBehaviorAttribute.AutoDisposeParameters to false to prevent WCF from calling IDisposable.Dispose on the parameter and return value objects. 然而,若某些參數要保留,其他參數要處置,則本事件是處置這些參數的最佳場所。However, if some parameters need to be preserved while others need to be disposed, this event is the best place to dispose those parameters.

此外,若配合雙工繫結,則在目前作業的回覆送出後,此事件可用來在回呼通道上傳送要求。Also, with duplex bindings, this event can be used to send a request on the callback channel after the reply for the current operation is sent.

注意

如果呼叫者正在接聽 OperationContext.OperationCompleted 作業的 OperationContractAttribute.IsTerminating 事件,當收到回應時,它可能會封鎖。If a caller is listening for the OperationContext.OperationCompleted event for an OperationContractAttribute.IsTerminating operation, it is possible to block when the response is received. 處理這種情況的正確方式是,當引發 OperationCompleted 時在另一個執行緒上排程工作,然後立即從該事件處理常式傳回。The proper way to handle this is to schedule work on another thread when OperationCompleted is raised and then immediately return from that event handler.

適用於