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.
It worked!
The .NET Framework hotfixes worked successfully.
Thank you very much Andrew.
Based on what is stated in those support pages it would seem that you need to contact MS' support: "To resolve this problem immediately, contact Microsoft Customer Support Services to obtain the hotfix.".
Hi Andrew,
How can i download this hotfix?
.Net 4.5, Win7: http://support.microsoft.com/kb/2848798/en-us
MS replied on the connect issue I submitted that this issue was previously fixed in a hotfix so you may want to get that.
Nothing simple comes to mind since you basically would have to ensure that no routed command is being executed (at least via the FindCommandBinding method in the CommandManager). So for this specific scenario that could mean re-templating the TabGroupPane and use your own command instead of the TabGroupPane.CloseSelectedItemCommand. Then put up your prompt and assuming it is not cancelled then execute the TabGroupPane.CloseSelectedItemCommand. But I'm sure you want to handle the other cases for which the item would have been closed so perhaps another option is to handle the event, set e.Cancel to true and then start a deferred action (e.g. begininvoke) and if the user doesn't cancel it then close the pane but keep some flag so you don't cancel it and start a deferred action.