InstanceDependencyProperty Class

Enables property sharing by the executing instances of an activity.

Namespace:  Microsoft.Rtc.Workflow.Activities
Assembly:  Microsoft.Rtc.Workflow (in Microsoft.Rtc.Workflow.dll)


<SerializableAttribute> _
Public NotInheritable Class InstanceDependencyProperty
public sealed class InstanceDependencyProperty
public ref class InstanceDependencyProperty sealed
Microsoft.Rtc.Workflow.Activities.InstanceDependencyProperty = function();



When an activity runs, a new instance may be created. Using an InstanceDependencyProperty ensures that the value of a property that is changed on the new instance will be kept in sync with the value of the property on the original activity. InstanceDependencyProperties are registered in the same way DependencyProperties are. An example is as follows:


    public readonly static InstanceDependencyProperty IncompleteTimeoutProperty = 
                     InstanceDependencyProperty.Register("IncompleteTimeout", typeof(TimeSpan), typeof(GetAndConfirmActivity), Globals.DefaultIncompleteTimeout);

The property is associated with the GetAndConfirm class, is of type TimeSpan and has a default value of Globals.DefaultIncompleteTimeout. The GetAndConfirm class must contain a (normal .Net) property called IncompleteTimeout. This property stores and retrieves values from the InstanceDependencyProperty as follows:


    public TimeSpan IncompleteTimeout
                     return (TimeSpan)GetValue(IncompleteTimeoutProperty);
                     SetValue(IncompleteTimeoutProperty, value);

Objects associated with an InstanceDependencyProperty (in the example above GetAndConfirm) must implement the IInstanceDependencyObject interface.

Using a default value negatively impacts performance. The value will be cloned before being used. The cloning process is usually slow. If you are sure that the property will be used (and that the cloning will take place), it is better to use SetValue to set the value. The value can then be retrieved without cloning.

Inheritance Hierarchy


See Also

InstanceDependencyProperty Members

Microsoft.Rtc.Workflow.Activities Namespace