vecino Well-Known Member Licensed User Longtime User Dec 9, 2021 #1 Hi, both ways work apparently the same, but what are the pros and cons of using one or the other option. Thank you. B4X: Copy Sub timgv1_Click(X As Int, Y As Int) CallSubDelayed3("","ControlarUbicacion",X,Y) End Sub Sub ControlarUbicacion( X As Int, Y As Int ) ' Do something here. End Sub B4X: Copy Sub timgv1_Click(X As Int, Y As Int) Wait For (ControlarUbicacion(X,Y)) complete (oRes As Object) End Sub Sub ControlarUbicacion( X As Int, Y As Int ) As ResumableSub ' Do something here. Return Null End Sub
Hi, both ways work apparently the same, but what are the pros and cons of using one or the other option. Thank you. B4X: Copy Sub timgv1_Click(X As Int, Y As Int) CallSubDelayed3("","ControlarUbicacion",X,Y) End Sub Sub ControlarUbicacion( X As Int, Y As Int ) ' Do something here. End Sub B4X: Copy Sub timgv1_Click(X As Int, Y As Int) Wait For (ControlarUbicacion(X,Y)) complete (oRes As Object) End Sub Sub ControlarUbicacion( X As Int, Y As Int ) As ResumableSub ' Do something here. Return Null End Sub
Solution Jeffrey Cameron Dec 9, 2021 They are very different mechanisms. With CallSubDelayed execution continues, and the called method is added to a "queue" that will be performed after the current sub exits (see https://www.b4x.com/android/forum/t...teract-between-activities-and-services.18691/) With WaitFor, the sub exits and stop processing with that statement. Execution will resume once the WaitFor condition is met (see https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/)
They are very different mechanisms. With CallSubDelayed execution continues, and the called method is added to a "queue" that will be performed after the current sub exits (see https://www.b4x.com/android/forum/t...teract-between-activities-and-services.18691/) With WaitFor, the sub exits and stop processing with that statement. Execution will resume once the WaitFor condition is met (see https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/)
Jeffrey Cameron Well-Known Member Licensed User Longtime User Dec 9, 2021 #2 They are very different mechanisms. With CallSubDelayed execution continues, and the called method is added to a "queue" that will be performed after the current sub exits (see https://www.b4x.com/android/forum/t...teract-between-activities-and-services.18691/) With WaitFor, the sub exits and stop processing with that statement. Execution will resume once the WaitFor condition is met (see https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/) Upvote 2 Solution
They are very different mechanisms. With CallSubDelayed execution continues, and the called method is added to a "queue" that will be performed after the current sub exits (see https://www.b4x.com/android/forum/t...teract-between-activities-and-services.18691/) With WaitFor, the sub exits and stop processing with that statement. Execution will resume once the WaitFor condition is met (see https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/)
vecino Well-Known Member Licensed User Longtime User Dec 9, 2021 #3 So, to summarize, I understand that CallSubDelayed continues to execute the following instructions. And WaitFor obviously waits for them to execute and then continues. Thank you very much. Upvote 0
So, to summarize, I understand that CallSubDelayed continues to execute the following instructions. And WaitFor obviously waits for them to execute and then continues. Thank you very much.