Skip to content

Clarify async scenarios and deadlocks #2112

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

Merged
merged 17 commits into from
Aug 22, 2025
Merged

Clarify async scenarios and deadlocks #2112

merged 17 commits into from
Aug 22, 2025

Conversation

adegeo
Copy link
Contributor

@adegeo adegeo commented Aug 18, 2025

Summary

A long time coming. Updates a few places with information about deadlocks and demonstrates code. Also adds reference to the new InvokeAsync methods in .NET 9.

Fixes #1406


Internal previews

📄 File 🔗 Preview link
dotnet-desktop-guide/winforms/controls/how-to-make-thread-safe-calls.md dotnet-desktop-guide/winforms/controls/how-to-make-thread-safe-calls
dotnet-desktop-guide/winforms/forms/events.md dotnet-desktop-guide/winforms/forms/events

Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk about a few aspects here.
We should also address .ConfigureAwait(true/false), and point out, how it can help in simplifying certain type of marshalling work, but can also impose deadlocks when applied poorly.

For the ValueTask issue in VB, I think I have a workaround, which we should provide in the docs.

@adegeo
Copy link
Contributor Author

adegeo commented Aug 21, 2025

@KlausLoeffelmann I addressed your feedback.

  • I also renamed snippets and code files to be clearer.
  • I removed code that was unused.
  • I also rewrote some of the snippets to better demonstrate the concepts being talked about here.
  • One other thing I did was reorder the bullet points to emphasize InvokeAsync, then Invoke, then BackgroundWorker.

@BillWagner BillWagner self-requested a review August 21, 2025 21:01
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good @adegeo You can :shipit: when ready.

Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't agree more with @BillWagner.
Nicely done!
@merriemcgaw FYI.

@adegeo adegeo merged commit e835765 into main Aug 22, 2025
6 checks passed
@adegeo adegeo deleted the winforms/1406/async branch August 22, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Async event handlers
3 participants