[PR #4051] [MERGED] Converts Dispatcher().RunAsync to WinRT Coroutines #25622

Open
opened 2026-01-31 09:10:39 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4051
Author: @mkitzan
Created: 12/24/2019
Status: Merged
Merged: 1/10/2020
Merged by: @undefined

Base: masterHead: coroutine-handlers


📝 Commits (8)

  • 548a51a First pass converting RunAsync to coroutines
  • 2e03f02 Gotta get into the habit of running the format script
  • 7803883 Use implicit this in coroutines
  • 4f59663 Tab and TerminalPage use this within locked scope
  • a17260f Added documentation and coroutine priority
  • 38b018c Review revisions and lambda pattern fix
  • 51dd2c7 Merge branch 'master' into coroutine-handlers
  • 80188be Merge branch 'master' into coroutine-handlers

📊 Changes

11 files changed (+253 additions, -214 deletions)

View changed files

📝 doc/STYLE.md (+1 -0)
📝 src/cascadia/TerminalApp/AppLogic.cpp (+27 -13)
📝 src/cascadia/TerminalApp/AppLogic.h (+4 -0)
📝 src/cascadia/TerminalApp/Pane.cpp (+14 -6)
📝 src/cascadia/TerminalApp/Pane.h (+1 -0)
📝 src/cascadia/TerminalApp/Tab.cpp (+21 -19)
📝 src/cascadia/TerminalApp/Tab.h (+4 -4)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+66 -69)
📝 src/cascadia/TerminalApp/TerminalPage.h (+7 -5)
📝 src/cascadia/TerminalControl/TermControl.cpp (+103 -94)
📝 src/cascadia/TerminalControl/TermControl.h (+5 -4)

📄 Description

Summary of the Pull Request

This PR turns all* instances of Dispatcher().RunAsync to WinRT coroutines 👌.
This was good coding fodder to fill my plane ride ✈️. Enjoy your holidays everyone!

*With the exception of three functions whose signatures cannot be changed due to inheritance and function overriding in TermControlAutomationPeer L44, L58, L72.

References

PR Checklist

  • Closes Pasting string to password prompt fails. (#3919)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #3919

Detailed Description of the Pull Request / Additional comments

My thought pattern here was to minimally disturb the existing code where possible. So where I could, I converted existing functions into coroutine using functions (like in the core example). For the most part all instances, I used the format where this is accessed safely within a locked scope. Some function signatures were changed to take objects by value instead of reference, so the coroutines don't crash when the objects are accessed past their original lifetime. The copy and paste event handler entry points were originally set to a high priority; however, the WinRT coroutines don't appear to support a priority scheme so this priority setting was not preserved in the translation.

Validation Steps Performed

Compiles and runs, and for every event with a clear trigger repro, I triggered it to ensure crashes weren't introduced.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4051 **Author:** [@mkitzan](https://github.com/mkitzan) **Created:** 12/24/2019 **Status:** ✅ Merged **Merged:** 1/10/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `coroutine-handlers` --- ### 📝 Commits (8) - [`548a51a`](https://github.com/microsoft/terminal/commit/548a51a38e3eff9147bfec4f1d75c45256157e85) First pass converting RunAsync to coroutines - [`2e03f02`](https://github.com/microsoft/terminal/commit/2e03f02d63b847c3f665352d34c4800554b14b0d) Gotta get into the habit of running the format script - [`7803883`](https://github.com/microsoft/terminal/commit/78038832885677b4983acd1ec45c277cb761de4c) Use implicit this in coroutines - [`4f59663`](https://github.com/microsoft/terminal/commit/4f596633533099c04a1268d5926ede56fd9c1a14) Tab and TerminalPage use this within locked scope - [`a17260f`](https://github.com/microsoft/terminal/commit/a17260f589b5c0f7bd754b172c2bcf43738d5707) Added documentation and coroutine priority - [`38b018c`](https://github.com/microsoft/terminal/commit/38b018cd8f8f4a7299d0ae3646507113042a2adf) Review revisions and lambda pattern fix - [`51dd2c7`](https://github.com/microsoft/terminal/commit/51dd2c7388fd753d4edce7314422a2a3fbafec86) Merge branch 'master' into coroutine-handlers - [`80188be`](https://github.com/microsoft/terminal/commit/80188be074168e5338c71387b3397a8e286ffa14) Merge branch 'master' into coroutine-handlers ### 📊 Changes **11 files changed** (+253 additions, -214 deletions) <details> <summary>View changed files</summary> 📝 `doc/STYLE.md` (+1 -0) 📝 `src/cascadia/TerminalApp/AppLogic.cpp` (+27 -13) 📝 `src/cascadia/TerminalApp/AppLogic.h` (+4 -0) 📝 `src/cascadia/TerminalApp/Pane.cpp` (+14 -6) 📝 `src/cascadia/TerminalApp/Pane.h` (+1 -0) 📝 `src/cascadia/TerminalApp/Tab.cpp` (+21 -19) 📝 `src/cascadia/TerminalApp/Tab.h` (+4 -4) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+66 -69) 📝 `src/cascadia/TerminalApp/TerminalPage.h` (+7 -5) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+103 -94) 📝 `src/cascadia/TerminalControl/TermControl.h` (+5 -4) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR turns all* instances of `Dispatcher().RunAsync` to WinRT coroutines 👌. This was good coding fodder to fill my plane ride ✈️. Enjoy your holidays everyone! *With the exception of three functions whose signatures cannot be changed due to inheritance and function overriding in `TermControlAutomationPeer` [`L44`](https://github.com/microsoft/terminal/blob/master/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp#L44), [`L58`](https://github.com/microsoft/terminal/blob/master/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp#L58), [`L72`](https://github.com/microsoft/terminal/blob/master/src/cascadia/TerminalControl/TermControlAutomationPeer.cpp#L72). <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #3919 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Requires documentation to be updated * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #3919 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments My thought pattern here was to minimally disturb the existing code where possible. So where I could, I converted existing functions into coroutine using functions (like in the [core example](https://github.com/microsoft/terminal/issues/3919#issue-536598706)). For ~the most part~ all instances, I used the format where [`this` is accessed safely within a locked scope](https://github.com/microsoft/terminal/issues/3919#issuecomment-564730620). Some function signatures were changed to take objects by value instead of reference, so the coroutines don't crash when the objects are accessed past their original lifetime. The [copy](https://github.com/microsoft/terminal/blob/master/src/cascadia/TerminalApp/TerminalPage.cpp#L1132) and [paste](https://github.com/microsoft/terminal/blob/master/src/cascadia/TerminalApp/TerminalPage.cpp#L1170) event handler entry points were originally set to a high priority; however, the WinRT coroutines don't appear to support a priority scheme so this priority setting was not preserved in the translation. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Compiles and runs, and for every event with a clear trigger repro, I triggered it to ensure crashes weren't introduced. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:10:39 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25622