178 views
in Embedded Wizard Studio by
I have an application built with multiple screens and buttons on each which use SwitchToDialog code to change between dialogs by I am running into scenarios where the application freezes if I press two screen change buttons at the same time or quickly press screen changes and I get the error message in the title.

Code below is how it's changed from a MAINMENU to AFT_SECTION application class.

TheApp.MAINMENU.Enabled = false;
TheApp.AFT_SECTION.Enabled = true;

Owner.SwitchToDialog( TheApp.AFT_SECTION, null, null, null, null, null, null, null, null, null, false );

Any suggestions on how to avoid this error?

1 Answer

0 votes
by
FYI, I was able to resolve this issue by simply adding this IsActiveDialog check prior to the switchtodialog method which prevents the issue I was having.

TheApp.MAINMENU.Enabled = false;
TheApp.AFT_SECTION.Enabled = true;

if ( IsActiveDialog( true ) == false ){
  return;
}

Owner.SwitchToDialog( TheApp.AFT_SECTION, null, null, null, null, null, null, null, null, null, false );
by

Hello blackmonsc,

perfect! This was the correct approach. Due to delays it is possibly that the application tries to present or dismiss a dialog twice. For all interested users see also the section Identify the active Dialogs and avoid race conditions explaining such scenarios.

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...