In my searching the common solution to this problem is to add an event handler to handle once the invoke operation has completed.
Unfortunately, my IValueConverter needs to return a value so having the handler is not much help. I have also tried a do/while loop until the operation is complete but the loop never closes.
I have also tried just a simple wait operation but it still returns null. I know that my DomainService returns the correct value but the Converter never gets to see it.
Is there anything I can do in this instance? Having a converter that works would remove/reduce pretty much all future problems I can forsee.
My code: (i need something like this that works)
InspectDomainContext context = new InspectDomainContext();
string name;
InvokeOperation<string> inv;
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string id = (string)value;
inv = context.GetName(id);
inv.Completed += new EventHandler(inv_Completed);
// return here after the handler has completed
return name;
}
void inv_Completed(object sender, EventArgs e)
{
name = inv.Value;
}