Skip to content

WI01110087 - Error creating window handle. - #40

Merged
jaywang-cn merged 2 commits into
masterfrom
JWA/WI01110087
Aug 14, 2026
Merged

WI01110087 - Error creating window handle.#40
jaywang-cn merged 2 commits into
masterfrom
JWA/WI01110087

Conversation

@jaywang-cn

Copy link
Copy Markdown

WI01110087 - Error creating window handle.

Reference:
dotnet#14823

dotnet#14826


// Handle should be created, before calling the BeginInvoke.
if (InvokeRequired && IsHandleCreated)
if (IsHandleCreated && InvokeRequired)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wow in that thread Microsoft just fixed by changing the if condition and not re-evaluating that the property has side effects.

Might be worth for us to remember that InvokeRequired seems to have side effects

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not necessarily side-effects.

Problem here was, that we checked first if an Invoke was required. But: To call that method, the control must have created the respective handle for the native Window it needs already. Now - if we do not have a handle, then InvokeRequired fails. So, switching this is safe here, because && is a short-circuit AND expression: If InvokeRequired returns false, then IsHandleCreated will not at all be called - since the whole expression does not have a chance at this point to become true, anyway (so, what's the point in calling the second one, right? 😸)

And that was exactly, what has happened every now and then: No Handle --> InvokeRequired was called anyway, and of course failed. Now: No Handle, we test that...and if there is none, then we bail early and do not touch InvokeRequired.

Hope the helps to shed a bit of light on this fix!

Happy weekend!

Klaus

Comment thread global.json
"version": "10.0.103",
"allowPrerelease": true,
"rollForward": "latestFeature",
"rollForward": "latestPatch",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does that need to change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

"latestFeature" will make the build failure, please check the failed result of master build, and the discussion in the teams channel

@jaywang-cn
jaywang-cn merged commit 4c8ba10 into master Aug 14, 2026
2 checks passed
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.

3 participants