Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Problem with XamDockManager/DocumentContentHost on application with Multiple UI threads
posted

I have an application with 2 UI threads.


The Main UI thread has a Main window with a XamDockManager and a DocumentContentHost Control which contains a Pane.
The second UI thread opens a Window with a ListBox, and starts a timer that inserts an item on ListBox every second.

When the main window pane's close button is clicked, a MessageBox is displayed in the RequestBeforeClose handler.

The problem appears when the second thread's window get focused while the main thread's MessageBox is displayed.

NOTE: If I show the MessageBox in other point of main thread  there is not any problem, the problem seems appear when the MessageBox is shown from RequestBeforeClose handler.

The second thread gets suspended and every DispatcherOperationCallbacks (ListBox insertions) get queued until main thread's MessageBox is closed

I Attach a C# solution that reproduces this problem.

Any ideas how to fix this?

Thanks.

MultiUIThreads_Test.zip
Parents
  • 54937
    Verified Answer
    Offline posted

    It seems like a problem in the WPF framework. Basically it will lock in the FindCommandBinding of the CommandManager while it is executing the command. As such when another thread gets into that method it too will lock on that method and essentially wait for the other thread to complete it's handling of that method which is where you are currently showing the message box. I've submitted the issue to MS. You should probably try to avoid any long running operations directly within those operations.

Reply Children