I have a Windows Forms program that hosts several WPF controls. It is a test execution tool. We have come across an issue where Invoke calls never return. This is happening for one of the tests plans written by one of our users.
The problem happens at different Invokes throughout the program. Two examples:
winForm.Invoke(new Action(() => wpfControl.DataContext = something));
Application.Current.Dispatcher.Invoke(new Action(() => result.Container.Clear()));
The thread calling Invoke never returns from the Invoke. I expected there was deadlock with the GUI thread, but the GUI thread is executing fine. Interestingly, all WinForm controls are behaving normally, but no WPF controls respond to the user. None of the other worker threads seem to be blocked.
Two questions come to mind:
- Does anyone have any debugging suggestions?
- Why would all WPF controls be blocked but all WinForm controls work fine?
Edit: I should have mentioned that this is may be a race condition of some sort. It is seen very infrequently and only after the application has been working normally for a while.
Snoop
tool. – Erti-Chris EelmaawinForm.Invoke
does not return to the next line then the whole application should not respond. – Vignesh.NDataContext
should be done in the same thread as the one in which the WPF control was created are you are sure that is the case ? Also tryBeginInvoke
instead – Vignesh.N