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

DispatcherHelper constructor throws expected exception, creates developer confusion #1434

Merged
merged 2 commits into from
Oct 11, 2019

Conversation

kmahone
Copy link
Member

@kmahone kmahone commented Oct 10, 2019

DispatcherHelper calls winrt::CoreApplication::GetCurrentView, and catches any exceptions that are thrown. This gives the functionally desired behavior, but it results in debugger exception noise. To avoid using exceptions as control flow, we avoid calling the cppwinrt api here and instead call directly into the abi.

See #1414

We also want this change to go into the OS. I will port the change there once this PR has been merged.

@kmahone kmahone requested a review from a team as a code owner October 10, 2019 23:22
Copy link
Contributor

@StephenLPeters StephenLPeters left a comment

Choose a reason for hiding this comment

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

:shipit:

@kmahone kmahone merged commit 6b75d80 into master Oct 11, 2019
@kmahone kmahone deleted the user/kmahone/dispatchertry branch October 11, 2019 19:51
@jevansaks jevansaks added the release note PR that we want to call out in the next release summary label Nov 8, 2019
oldnewthing added a commit to oldnewthing/microsoft-ui-xaml that referenced this pull request May 22, 2020
Improvement to microsoft#1434 by switching from
CoreApplicationView::GetForCurrentThread to
CoreWindow::GetForCurrentThread. The difference is that
CoreApplicationView::GetForCurrentThread throws if not called on a UI
thread, whereas CoreWindow::GetForCurrentThread just returns null.
The CoreWindow and CoreApplicationView have the same dispatcher,
and switching to CoreWindow removes the need to work around the
CoreApplicationView behavior.
ranjeshj pushed a commit that referenced this pull request May 27, 2020
Improvement to #1434 by switching from
CoreApplicationView::GetForCurrentThread to
CoreWindow::GetForCurrentThread. The difference is that
CoreApplicationView::GetForCurrentThread throws if not called on a UI
thread, whereas CoreWindow::GetForCurrentThread just returns null.
The CoreWindow and CoreApplicationView have the same dispatcher,
and switching to CoreWindow removes the need to work around the
CoreApplicationView behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release note PR that we want to call out in the next release summary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants