I'm using wpf window to display a modeless dialog inside credential provider.
I am setting the parent for my window using WindowInteropHelper.
In most cases everything works fine, but in rare cases the window stops responding to the keyboard. KeyDown events arrive, but no character messages appear.
Probably the reason is that I use Show instead of ShowDialog like described here https://stackoverflow.com/a/52089207/22586113.
Has anyone tried using a modeless window from a provider? What are the correct steps to do this?
Show window in most cases works fine, but in very rare cases the window stops responding to the keyboard.
If I correctly understood the advice to make a separate thread for my window, then below is an example of code that does this:
The credential provider receives the handle of the parent window (
via OnCreatingWindow) and creates a window in a new UI thread where it sets the parent viainteropHelper.Owner = ownerHwnd. Then, when the provider needs to show or hide the window, it calls the appropriate show/hide methods.The interesting thing is that the parent window is created on a thread different from the one in which the provider methods are executed:
credentialProviderThreadId != parentWindowThreadId.