Share via


Terminating a Conversation

The recommended way for an application can terminate a conversation is as follows, by calling one of the BeginTerminate() overloaded methods on the Conversation instance.

The following code example demonstrates terminating an existing conversation.

Conversation conversation = new Conversation(endpoint);
...
conversation.BeginTerminate(Conversation_TerminateCompleted, conversation);

void Conversation_TerminateCompleted(IAsyncResult asyncResult)
{
    Conversation conversation = asyncResult.AsyncState as Conversation;
    conversation.EndTerminate(asyncResult);    // Should not throw.
}