Winforms WPF Interop - Wpf Controls Turned Inactive

I have a similar problem with this question regarding the coloring of wpf controls

The application I'm working on is a fairly large application for Windows forms with several wpf user controls throughout the application. The problem arises in the application plugin, in which the third-party C ++ library is called in a separate thread, WndProc is redefined to receive progress updates from the third-party library. I have yet to determine the exact scenario that is causing the problem, but similar to the above question, after several starts, the wpf controls cannot draw and update.

Adjusting the width of elementhosts solves the problem with the picture for most controls, but after that all the wpf controls in the application seem to become "non-responsive" - ​​visually ... progress bars cannot show progress (although the value changes), the scroll bars do not respond , selecting an item in the list does not highlight it (it becomes highlighted after resizing, and in fact it becomes selected - you just see that it is selected), tree images are not drawn after resizing, it shows flushes only a black background, where it should be a tree (although, when I click on the items where they need to be in the tree structure, the events are trigeramirovannymi)

I know that I should probably find out the root of the problems that lead to the first (his case happens in a rather random way and is difficult to trap) - although using a breakpoint in the WndProc method does crash on a regular basis ...

What I was hoping for is a way to "reactivate" / update all other controls throughout the application ... I am an intermediate developer of wpf, C # and still do not know enough about messages and events that occur in the background, to make good use of them ... my thought is that some kind of event or message that wpf tells to redraw needs to be broken or interrupted, or something like that - how can I determine what is broken and maybe activate it?

Any advice would be much appreciated ...

thanks

+4
source share
1 answer

Perhaps the event that triggers the visualization of the WPF graphical control is never handled due to the WndProc override.

Because you interact with WinForms, you can force events to be processed by calling Application.DoEvents(); somewhere. Perhaps after updating the progress bar.

0
source

All Articles