Notifier is not like messagebox and wait decision before running the next line of code

In the button event, I put notifier first, the button event finished first and value from Notifier will be sent at last.


In my example, I simplified the coding.

  • Initial global_strNotificationGeneral = 0
  • Notifier messagebox pop up
  • Choose Confirm Button
  • Lbl_testing.text showed 0.

I run the program again. In this time, I choose the Cancel button. The lbl_testing.text showed 1.

I run the program again. In this time, I choose the Cancel button. The lbl_testing.text showed 0.

I run the program again. In this time, I choose the Confirm button. The lbl_testing.text showed 0.

I run the program again. In this time, I choose the Confirm button. The lbl_testing.text showed 1.

At the moment, I put the notifier at last and I put some procedure inside AfterChoosing. This would solve my issue.

I think the program did not stop at the point of Notifier. Is it the defect from MIT App?

No, not a defect in Ai2 :wink:

Put your procedure “sub_Confirm_Delete2” in the “then” section of your “afterChoosing” event, where the output = 1.

Unless you need them for a reason you could get rid of the sub routine and variable and just put the two set label blocks in the afterChoosing event.

1 Like

This is the expected behavior. Blocks run on what is called the user interface (UI) thread. Therefore, no user interaction can occur within a stack of blocks, so the dialog doesn't actually appear until after the button event code completes. The ShowChooseDialog block shows the choose dialog, but it cannot pause execution due to the asynchronous nature of user interface programming. When the user clicks a button in the dialog, the AfterChoosing event is run to report the result back to your app, so anything you want to happen after the dialog should go there.

2 Likes

Thanks for your explanation. I understood the flow now.

I learnt a little bit VB long time ago. I thought their dialog block allows pause execuation. Let user to make decision before execuate the rest of code. If I am wrong, please let me know.

Does MIT has similar dialog box and pause execution? Anyway, this is not critical as I put sub procedure into AfterChoosing event. However, it would be great if MIT has such dialog box.

Thanks.

Yes, if you get your workflow correct (by which I mean you do not execute anything until after choosing), the Notifier Choose dialog will stop execution until the user has made a choice

Why is a wait procedure generally a bad idea?
The model of event processing in App Inventor by Lyn
Please Wait method by Scott

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

TImAI2. I afraid ShowChooseDialog won’t pause execuation. I tried and ewpatton explained the asynchronous nature.

Taifun. Thanks for the concept why wait procedure generally a bad idea. You gave me a lot of good information. However, my knowledge is limited. In the artical, did it describe using timer, delay the action and allow us to get enough time to press button to change the value of variables?

if you want to wait, then follow the Please Wait method by Scott
Taifun