wpf icon indicating copy to clipboard operation
wpf copied to clipboard

please add Task event to controls

Open ali50m opened this issue 1 year ago • 4 comments

It's 2024 now... Please don't let the button.click event to handle async/await task with async void signature.

ali50m avatar Apr 23 '24 05:04 ali50m

This would be a significant breaking change on several levels, existing code would no longer compile, the events would have different signature and the behavior would change (e.g. exception handling). The only way to solve this in backwards compatible way that comes to my mind is to duplicate all the events with their async counterparts, e.g. have ClickAsync etc. Even then, you might need to deal with events being fired before other events finished.

I don't say it often, but I suggest to see how this is resolved in Winforms first. Relevant discussion: https://github.com/dotnet/winforms/issues/6478

miloush avatar Apr 23 '24 08:04 miloush

@miloush thanks for the redirection to winform similar issues. Is there a already WPF progress issue for tracking this? I think WPF guys also want the async control event.

ali50m avatar Apr 23 '24 15:04 ali50m

It is not really a WPF specific problem, but no, I think this is the first issue in this repo that can be used to track it.

Would you mind sharing why async void event handlers don't work for you, or what kind of scenarios are you currently unable to realize?

miloush avatar Apr 23 '24 16:04 miloush

No, I am doing WPF mainly with CommunityToolkit.Mvvm package, which can call the async task through AsyncRelayCommand.

I am doing some research with Blazor these days. I think the OnInitialized/OnInitializedAsync like method is more convenient than WPF when invoking event handler in code behind.

ali50m avatar Apr 24 '24 00:04 ali50m