Conversations expose several events that can be useful to an application, and may represent a good handle for the application developer to invoke business logic, or adjust a user interface. For example, the StateChangedevent is raised when the state of the conversation changes, and the PropertiesChangedevent is raised when a property of the conversation such as Subjector Idchanges.

The following code demonstrates registering for the StateChangedevent and the implementation of a simple handler for this event.

Copy Code
conversation.PropertiesChanged += Conversation_PropertiesChanged;

private void Conversation_PropertiesChanged(object sender,
PropertiesChangedEventArgs<ConversationProperties> e)
{
  if (e.ChangedPropertyNames != null)
  {
	//Update the property from property changed event
	foreach (string propertyName in e.ChangedPropertyNames)
	{
	switch (propertyName)
	{
		case ConversationProperties.ConversationIdPropertyName: 
		Console.WriteLine("Conversation id changed to {0}",
e.Properties.Id);
		break;
		case
ConversationProperties.ConversationPriorityPropertyName: 
		Console.WriteLine("Conversation priority changed to {0}",
e.Properties.Priority);
		break;
		case
ConversationProperties.ConversationSubjectPropertyName:
		Console.WriteLine("Conversation subject changed to {0}",
e.Properties.Subject);
		break;
		case
ConversationProperties.ConversationActiveMediaTypesPropertyName:
		Console.WriteLine("Conversation active media types
property name changed to");
		foreach (string activeMedia in
e.Properties.ActiveMediaTypes)
		{
			Console.WriteLine(activeMedia);
	}
		break;
		default:
		//Should not reach here
		Debug.Assert(false, "property name not expected");
		break;
}
}
  }
}