Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please add Task event to controls #9045

Open
ali50m opened this issue Apr 23, 2024 · 4 comments
Open

please add Task event to controls #9045

ali50m opened this issue Apr 23, 2024 · 4 comments

Comments

@ali50m
Copy link

ali50m commented Apr 23, 2024

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

@ali50m ali50m changed the title please make add types event to controls please make add Task event to controls Apr 23, 2024
@ali50m ali50m changed the title please make add Task event to controls please add Task event to controls Apr 23, 2024
@miloush
Copy link
Contributor

miloush commented Apr 23, 2024

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: dotnet/winforms#6478

@ali50m
Copy link
Author

ali50m commented Apr 23, 2024

@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.

@miloush
Copy link
Contributor

miloush commented Apr 23, 2024

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?

@ali50m
Copy link
Author

ali50m commented Apr 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants