AvaloniaUI / Avalonia.Xaml.Behaviors

Port of Windows UWP Xaml Behaviors for Avalonia Xaml.
MIT License
396 stars 48 forks source link

CallMethodAction with async methods #65

Closed mightypanda closed 2 years ago

mightypanda commented 3 years ago

Hello and thank you for this beautiful piece of software! I noticed that async methods, returning Task, are not supported by CallMethodAction. Is it difficult to add this possibility? Thank you

mightypanda commented 2 years ago

Hello Wieslaw, I had the need for a new project and just created a clone of your CallMethodAction. I needed just to add the check for the returntype being a Task, and it worked flawlessly.

CallMethodAction.cs line 181 if (string.Equals(method.Name, MethodName, StringComparison.Ordinal) && (method.ReturnType == typeof(void) || method.ReturnType == typeof(System.Threading.Tasks.Task)) && method.IsPublic)

Maybe you can integrate it into your new releases.

Best