in GUI Development by
Screen is an active object in the global class DeviceClass. This is caused under rare circumstances but it causes a serious crash when it does happen and I'd like to understand how to prevent this group. Debugging it, it looks like it's losing it's modal status before the 2 calls get called:


Additionally, this seems to happen more when we're doing stress testing by pressing two buttons really quickly causes 2 different dialogs to come up.

1 Answer

0 votes
Best answer


I suppose this is a race condition. While the user intearcts with application, some timers may expire, animations are running or pending signals are delivered, the corresponding operation may interleave. Let's image the situation of a menu with some CLOSE menu item and an integrated timer to automatically close the menu. It is possible, that the user activates the CLOSE item just in the same moment when the timer expires. Accordingly the methods associated with the CLOSE item and the timer are executed. If both perform the same operation, e.g. EndModal(), the first method succeds and the second fails, since the affected group is not modal anymore. Similar happens when you add/remove one group. Doing this twice will end in an error case.

What you can do?

Wherever such race condition is possible add additional if-condition to the begin of the respective method to test whether the affected group is really modal, visible, etc. You can, for example, test the variable Owner of the affected group. If Owner is null, the group is already removed:

// If Screen is already 'closed' exit immediately
if ( Screen.Owner == null )

GetRoot().EndModal( Screen );
Root.Remove( Screen );

Hope it helps you further

Best regards

Paul Banach

Thank you Paul. I'll add that additional check before I remove any screens.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint