Repository navigation
Port wil::resume_foreground - #1574
Open
Yexuan Xiao (YexuanXiao) wants to merge 4 commits into
Open
Yexuan Xiao (YexuanXiao) wants to merge 4 commits into
Yexuan Xiao (YexuanXiao) wants to merge 4 commits into
Conversation
|
PLEASE accept this pull request - having to import WIL just to do resume_foreground is unfortunate. The advanced threading documentation for cpp/winrt still have the resume_foreground example for the more general use case of obtaining the UI thread and omit the WIL requirement. It took me a whole day to figure out that WIL was required (although it is discussed in the migration docs). Looks like this pull is ready to approve 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR ports
wil::resume_backgroundwith a few small improvements:operator()instead ofSchedule, support using lambdas to replace cumbersome struct definitions.dispatcher_state_guardinstead oftry {} catch (...) { throw; }pattern, which help compiler generates cleaner code.C++/WinRT 3.0 should fix this issue, as it could cause coroutines to run on the wrong thread or leak. Since almost no one checks the return value of
co_await, this will hardly break existing code.C++/WinRT already has special handling for WinUI (
base_xaml_component_connector_winui.h), so unless there are plans to remove that code from C++/WinRT, support forMicrosoft::UI::Dispatching::DispatcherQueueshould not be rejected.The tests are also port from wil, identical except for the namespace name.