dotnet / dotnet/wpf

HwndHost fail to end thread model state

Open
#8,172 8 comments 0 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

I have a WPF app, it needs to embed another app which is written as a Winform app. So I used HwndHost to embed it.
It works fine. I used .Net Framework 4.7.2

But when the Winform App shows a model form, such as a message box, and at that moment, i kill the process of Winform App in system TaskManager, without clicking the message box button. Then the WPF app will not reponse to any mouse click nor keyboard input.

I think the reason is the winform app stop at a model state, and the WPF app can't quit that state.

### Reproduction Steps

1. write a WPF app, and a HwndHost control
2. write a Winform app, it has a button to show message box
3. embed the Winform app. click the button to show message box, without cliking any confirm/cancel button
4. kill the process of winform app in TaskManager
5. then the wpf app hangs

### Expected behavior

when the winform app ends, the wpf app should run normally to response any mouse or keyboard input

### Actual behavior

the wpf app will hang, i have to kill the process of WPF app

### Regression?

_No response_

### Known Workarounds

I tried to exit thread model state, but I don't know how to do it

### Impact

_No response_

### Configuration

Windows 10, .net framework 4.7.2

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.