I have a dependency property in the class, let's call it "SomethingControl":
public static readonly DependencyProperty SomethingProperty = DependencyProperty.Register("Something", typeof(Something), typeof(SomethingControl), new UIPropertyMetadata(SomethingGotSet));
And I defined a callback method that is passed to the UIPropertyMetadata constructor as asynchronous:
private async static void SomethingGotSet(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (SomethingControl)d;
if (control != null)
{
control.SomeOtherProperty = await AsynchronousMethodCall();
}
}
Is it safe to do this? Will this cause a dead end or problems in the user interface thread? I tested it and everything seems to be fine, but I cannot find anything in the MSDN documentation using asynchronous property callback methods like this.
source
share