Jim Brown Active Member Licensed User Longtime User Jun 3, 2014 #1 Is there a way to force the MainForm to update its components? My basic problem is: 1) User selects a menu action which leads to an intensive routine 2) I want to update a status textfield before the routine runs - E.g, "Working ..." The issue is, although I call MyTextField.Text="Working .." before the intensive routine the actual update to the text field does not happen until the menu action sub is completed. I need something like: Code: Copy Sub menu_DoStuff_Action MyTextField.Text="Working .." MainForm.Update ' <--------------- THIS Do_Big_Task_Here MyTextField.Text="Done" End Sub Thanks
Is there a way to force the MainForm to update its components? My basic problem is: 1) User selects a menu action which leads to an intensive routine 2) I want to update a status textfield before the routine runs - E.g, "Working ..." The issue is, although I call MyTextField.Text="Working .." before the intensive routine the actual update to the text field does not happen until the menu action sub is completed. I need something like: Code: Copy Sub menu_DoStuff_Action MyTextField.Text="Working .." MainForm.Update ' <--------------- THIS Do_Big_Task_Here MyTextField.Text="Done" End Sub Thanks
stevel05 Expert Licensed User Longtime User Jun 3, 2014 #2 You could try using CallSubDelayed to call the big sub, you would need a callback sub which is called when the routine finishes which in your example would update the MyTextField.Text. Upvote 0
You could try using CallSubDelayed to call the big sub, you would need a callback sub which is called when the routine finishes which in your example would update the MyTextField.Text.
Erel B4X founder Staff member Licensed User Longtime User Jun 4, 2014 #3 BTW, what is the "intensive task" actually doing? Maybe it can be optimized. Upvote 0
Jim Brown Active Member Licensed User Longtime User Jun 4, 2014 #4 Thanks Steve, I will look at the CallSubDelayed option. Hi Erel, The task is a sprite cutter, which scans through an image for individual sprites. Now, the bigger the sprite sheet image the longer the process will take. The only thing is, the application looks like it has frozen for 1-2 seconds until the routine has completed (the sub ends). Everything is happening inside the Sub menu_DoStuff_Action ... End Sub I actually want to show a spinning progress bar and update the text box. Although I am taking care of these before running the loop they never get updated. Perhaps if possible an .Invalidate method could be added to force the UI elements in question to refresh? Code: Copy MyTextField.Text="Working .." MyProgress.Visible=True MyTextField.Invalidate MyProgress.Invalidate Upvote 0
Thanks Steve, I will look at the CallSubDelayed option. Hi Erel, The task is a sprite cutter, which scans through an image for individual sprites. Now, the bigger the sprite sheet image the longer the process will take. The only thing is, the application looks like it has frozen for 1-2 seconds until the routine has completed (the sub ends). Everything is happening inside the Sub menu_DoStuff_Action ... End Sub I actually want to show a spinning progress bar and update the text box. Although I am taking care of these before running the loop they never get updated. Perhaps if possible an .Invalidate method could be added to force the UI elements in question to refresh? Code: Copy MyTextField.Text="Working .." MyProgress.Visible=True MyTextField.Invalidate MyProgress.Invalidate
stevel05 Expert Licensed User Longtime User Jun 4, 2014 #5 Try putting DoEvents calls within the sub. That should allow the Gui to continue. The other option is to lock the Gui, with a panel that has it's click's consumed and run the process in a thread, which will allow the Gui to maintain the progress bar if it's set as indeterminate.. Upvote 0
Try putting DoEvents calls within the sub. That should allow the Gui to continue. The other option is to lock the Gui, with a panel that has it's click's consumed and run the process in a thread, which will allow the Gui to maintain the progress bar if it's set as indeterminate..
Erel B4X founder Staff member Licensed User Longtime User Jun 5, 2014 #6 There is no DoEvents method in B4J (due to technical reasons). You can split the task into several tasks and then use CallSubDelayed to start each task. Another option is to use the threading library and run this task with a background thread. Upvote 0
There is no DoEvents method in B4J (due to technical reasons). You can split the task into several tasks and then use CallSubDelayed to start each task. Another option is to use the threading library and run this task with a background thread.
Jim Brown Active Member Licensed User Longtime User Jun 5, 2014 #7 Thanks both. CallSubDelayed() turns out to be a very good solution. Upvote 0
stevel05 Expert Licensed User Longtime User Jun 5, 2014 #8 Try putting DoEvents Click to expand... oops, still in B4a mode! Upvote 0