Shay Well-Known Member Licensed User Longtime User Feb 10, 2012 #1 Hi I am using the following, and it does not show the message the 2 subs inside takes 4 sec, so I should have seen something ifi put break, I can see the message ProgressDialogShow("Please wait") Read_Settings Read_Logs ProgressDialogHide
Hi I am using the following, and it does not show the message the 2 subs inside takes 4 sec, so I should have seen something ifi put break, I can see the message ProgressDialogShow("Please wait") Read_Settings Read_Logs ProgressDialogHide
O Omar Member Licensed User Longtime User Feb 10, 2012 #2 Hello Shay, It's probably executing the code quicker than you expected ( are your sure it takes 4 sec to execute) and this is why the dialog is probably being hidden immediately. Shay said: Hi I am using the following, and it does not show the message the 2 subs inside takes 4 sec, so I should have seen something ifi put break, I can see the message ProgressDialogShow("Please wait") Read_Settings Read_Logs ProgressDialogHide Click to expand... Upvote 0
Hello Shay, It's probably executing the code quicker than you expected ( are your sure it takes 4 sec to execute) and this is why the dialog is probably being hidden immediately. Shay said: Hi I am using the following, and it does not show the message the 2 subs inside takes 4 sec, so I should have seen something ifi put break, I can see the message ProgressDialogShow("Please wait") Read_Settings Read_Logs ProgressDialogHide Click to expand...
S susu Well-Known Member Licensed User Longtime User Feb 10, 2012 #3 Try this code: ProgressDialogShow("Please wait") DoEvents Read_Settings DoEvents Read_Logs DoEvents ProgressDialogHide Click to expand... Upvote 0
Try this code: ProgressDialogShow("Please wait") DoEvents Read_Settings DoEvents Read_Logs DoEvents ProgressDialogHide Click to expand...
Shay Well-Known Member Licensed User Longtime User Feb 10, 2012 #4 The DoEvents solved it can you explain why? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Feb 10, 2012 #5 UI elements are drawn and updated through the main thread message loop. When the main thread runs your code it isn't able to handle the messages. The messages wait till the main thread is free. By calling DoEvents you allow the main thread to process UI related messages. Upvote 0
UI elements are drawn and updated through the main thread message loop. When the main thread runs your code it isn't able to handle the messages. The messages wait till the main thread is free. By calling DoEvents you allow the main thread to process UI related messages.
Shay Well-Known Member Licensed User Longtime User Feb 10, 2012 #6 I gave simple example what happens if i have many commands after the "show" do I need to put doevents after each line - it is 100+ lines Upvote 0
I gave simple example what happens if i have many commands after the "show" do I need to put doevents after each line - it is 100+ lines
stevel05 Expert Licensed User Longtime User Feb 10, 2012 #7 It'll be a trade off between how often you want the Progress to update and how much you want to slow down the actual process. I would think updating the progress bar every second is enough, so experiment with the placement, although the results will probably be different with different devices. Upvote 0
It'll be a trade off between how often you want the Progress to update and how much you want to slow down the actual process. I would think updating the progress bar every second is enough, so experiment with the placement, although the results will probably be different with different devices.
Shay Well-Known Member Licensed User Longtime User Feb 10, 2012 #8 any other solution for "sand clock" when I don't know how much time task can take, and I want to show something meanwhile thanks Upvote 0
any other solution for "sand clock" when I don't know how much time task can take, and I want to show something meanwhile thanks
stevel05 Expert Licensed User Longtime User Feb 10, 2012 #9 If the process that is taking a long time has no other UI updates, you could run it in a separate thread, the progress bar will then keep running in the main thread. Or you could look at the RunOnGuiThread if there are some UI updates (not tried that though). Attachments ttest.zip ttest.zip 6 KB · Views: 564 Last edited: Feb 10, 2012 Upvote 0
If the process that is taking a long time has no other UI updates, you could run it in a separate thread, the progress bar will then keep running in the main thread. Or you could look at the RunOnGuiThread if there are some UI updates (not tried that though).
Johan Schoeman Expert Licensed User Longtime User Nov 21, 2014 #10 I have tried to call DoEvents inside a timer but had no joy with it - even when setting the timer interval as low as 1ms (went to max 1000ms). Placed some DoEvents calls inside some of the nested for/next loops inside my code and could then see the ProgressDialog....Thought that by using a timer the UI related massages (in this case the ProgressDialog) would have had sufficient time to update- especially with the interval set to 1000ms? Upvote 0
I have tried to call DoEvents inside a timer but had no joy with it - even when setting the timer interval as low as 1ms (went to max 1000ms). Placed some DoEvents calls inside some of the nested for/next loops inside my code and could then see the ProgressDialog....Thought that by using a timer the UI related massages (in this case the ProgressDialog) would have had sufficient time to update- especially with the interval set to 1000ms?
Erel B4X founder Staff member Licensed User Longtime User Nov 23, 2014 #11 Please start a new thread and post the relevant code. Upvote 0