cancel
Showing results for 
Search instead for 
Did you mean: 

UI Freezing when TxMessageBox is Used

Hello fellow developers!!

 

I have been developing in Process Simulate for 6 years.  Up until recently I have utilized winforms in Commands and Viewers.  I am rewriting my DCS Modeling Designer viewer utilizing a WPF UI with MVVM pattern.  I ran into an issue with utilizing the TXMessageBox.Show().  It is called in a catch block, which is in a service class for creating modeling objects to catch any uncaught errors that may relate to missing parameters that I cannot control.  The Service Class Method is called by a ViewModel method that is connected to a property changed event, namely a value changed in the numeric up down control I pulled down from Nuget.

 

I eliminated it being any UI related issues in the binding such as maybe it being a value changed in the Nuget control .dll getting stuck by eliminating the Message Box call and running it, so it is the TxMessageBox.Show causing the problem.  Has anyone else had issues like this?

5 REPLIES

Re: UI Freezing when TxMessageBox is Used

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Cliff_Knasinski,

 

Can you send a small example so we can analyze the problem?

We are using the TxMessageBox with WPF dialogs and we haven't experienced that problem.

 

 

Best Regards,

DianaG

Re: UI Freezing when TxMessageBox is Used

Experimenter
Experimenter

Cliff, 

 

Have you insured you are on the same thread as well?

 

 

 

Im not having any issues with TxMessageBox but at times have seen some weird behavior with other controls using MVVM, I think it was mostly the TxNumericUpDownEditControl, but thats because its not NativeWPF but a wrapper that is basically using a WinForms control within it, so i had to rewrite the control to get the functionality i wanted from it.

 

Make sure that you turn on debugging at least when your stepping through to a higher level

 

I may be wrong but Tools/Options/ and then type debug. I usually in VS the options are set to warning, set them all to information and it will spit out alot more info for you.

 

 

 

 

Re: UI Freezing when TxMessageBox is Used

I would have to send the whole project for you to replicate the propble.  Like the post below I am suspecting it is a thread issue with the numeric control I implemented.

 

The error is in:

"Dispatcher processing has been suspended, but messages are still being processed."

System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

 

If I have time to fully investigate it I will post any resolution here.  I just switched back to the basic MessageBox to resolve it.

Re: UI Freezing when TxMessageBox is Used

I am guessing this is Mr C. B. ? I am certain it is a threading issue with the numeric control. Thanks for the tip with the debugger.  I did not realize VS was hiding so much useful information about WPF components and such while debgging.

 

It is not a hot issue since I have a work around. But I have determined it is a problem with the numeric control.  It has seperate handlers for when a value is typed in and when the up down buttons are used.  I am going to replace it with something tailored by me to work correctly when I have the time to tinker with writng my own control for it.

Re: UI Freezing when TxMessageBox is Used

Experimenter
Experimenter

if its a threading issue, then you have to remember ps doesnt support multithreading.

 

if your using MVVM Light, you have to make sure you register the dispatcherhelper but then you could use the DispatcherHelper to keep thing synchronous.. otherwise you can

 

 public static bool InvokeRequired(this Dispatcher dispatcher)
        {
            return !dispatcher.Thread.Equals(Thread.CurrentThread);
        }


use with

var action = ()=> ActionToExecute();

var required = InvokeRequired(Application.Current.Dispatcher);

if(required)
 Application.Current.Dispatcher.BeginInvoke(action);
else
 action();