LucaMs Expert Licensed User Longtime User Dec 30, 2020 #1 I would like to avoid forcing the user of my class to use "WAIT FOR" while waiting for a class routine to finish moving a View. Example (Duration, SomeView, ... fake stuff, only as example) B4X: Copy ' clsMyClass Public Sub Move SomeView.SetLayoutAnimated(Duration, 100, ...) End Sub I wish the user-developer could write like this: B4X: Copy objMyClass.Move Log("Done") ' <--- this line executed only after Duration ms And not like: B4X: Copy Wait For (objMyClass.Move) Complete(Unused As Boolean) Log("Done") ' <--- this line executed only after Duration ms
I would like to avoid forcing the user of my class to use "WAIT FOR" while waiting for a class routine to finish moving a View. Example (Duration, SomeView, ... fake stuff, only as example) B4X: Copy ' clsMyClass Public Sub Move SomeView.SetLayoutAnimated(Duration, 100, ...) End Sub I wish the user-developer could write like this: B4X: Copy objMyClass.Move Log("Done") ' <--- this line executed only after Duration ms And not like: B4X: Copy Wait For (objMyClass.Move) Complete(Unused As Boolean) Log("Done") ' <--- this line executed only after Duration ms
Erel B4X founder Staff member Licensed User Longtime User Dec 30, 2020 #2 No such thing. If the user wants that the code will wait for something to complete then they need to use Wait For. Upvote 0
No such thing. If the user wants that the code will wait for something to complete then they need to use Wait For.
LucaMs Expert Licensed User Longtime User Dec 30, 2020 #3 Erel said: No such thing. If the user wants that the code will wait for something to complete then they need to use Wait For. Click to expand... I suspected it. Also begin to suspect that you see while I am writing the question, because I did not have time to post it that you had already answered ? Upvote 0
Erel said: No such thing. If the user wants that the code will wait for something to complete then they need to use Wait For. Click to expand... I suspected it. Also begin to suspect that you see while I am writing the question, because I did not have time to post it that you had already answered ?
josejad Expert Licensed User Longtime User Dec 30, 2020 #4 LucaMs said: Also begin to suspect that you see while I am writing the question, because I did not have time to post it that you had already answered Click to expand... I have thought it too a couple of times. Upvote 0
LucaMs said: Also begin to suspect that you see while I am writing the question, because I did not have time to post it that you had already answered Click to expand... I have thought it too a couple of times.
agraham Expert Licensed User Longtime User Dec 30, 2020 #5 LucaMs said: wish the user-developer could write like this: Click to expand... Erel said: No such thing. Click to expand... For clarification, the reason it is not possible is that for Wait For to work the sub-routine call stack has to be totally unwound back to the message loop, which means that every call has to return. So your objMyClass.Move has to return or it will block and not let the message loop process the wait. Upvote 0
LucaMs said: wish the user-developer could write like this: Click to expand... Erel said: No such thing. Click to expand... For clarification, the reason it is not possible is that for Wait For to work the sub-routine call stack has to be totally unwound back to the message loop, which means that every call has to return. So your objMyClass.Move has to return or it will block and not let the message loop process the wait.
AnandGupta Expert Licensed User Longtime User Dec 30, 2020 #6 Erel said: No such thing. Click to expand... This I think is due to ASynchronization logic of Android. @LucaMs , I think, you want is Synchronization logic, like old msgbox logic. Regards, Anand Upvote 0
Erel said: No such thing. Click to expand... This I think is due to ASynchronization logic of Android. @LucaMs , I think, you want is Synchronization logic, like old msgbox logic. Regards, Anand
Erel B4X founder Staff member Licensed User Longtime User Dec 30, 2020 #7 AnandGupta said: This I think is due to ASynchronization logic of Android. Click to expand... Nope. It has nothing to do with Android. The resumable subs feature is a 100% B4X compiler feature. Upvote 0
AnandGupta said: This I think is due to ASynchronization logic of Android. Click to expand... Nope. It has nothing to do with Android. The resumable subs feature is a 100% B4X compiler feature.
AnandGupta Expert Licensed User Longtime User Dec 30, 2020 #8 Erel said: The resumable subs feature is a 100% B4X compiler feature. Click to expand... So, Lucas can put the 'wait for' in his class itself (maybe with some parameter) and compiler will work. No need for 'wait for' in calling program . Regards, Anand Upvote 0
Erel said: The resumable subs feature is a 100% B4X compiler feature. Click to expand... So, Lucas can put the 'wait for' in his class itself (maybe with some parameter) and compiler will work. No need for 'wait for' in calling program . Regards, Anand
Cableguy Expert Licensed User Longtime User Dec 30, 2020 #9 Erel said: Nope. It has nothing to do with Android. The resumable subs feature is a 100% B4X compiler feature. Click to expand... So this means that no other language that targets Android has this feature ?? Upvote 0
Erel said: Nope. It has nothing to do with Android. The resumable subs feature is a 100% B4X compiler feature. Click to expand... So this means that no other language that targets Android has this feature ??
agraham Expert Licensed User Longtime User Dec 30, 2020 #10 AnandGupta said: So, Lucas can put the 'wait for' in his class itself (maybe with some parameter) and compiler will work. No need for 'wait for' in calling program . Click to expand... Wrong, I'm afraid. As Erel said it won't work. Read my post #5 above. Upvote 0
AnandGupta said: So, Lucas can put the 'wait for' in his class itself (maybe with some parameter) and compiler will work. No need for 'wait for' in calling program . Click to expand... Wrong, I'm afraid. As Erel said it won't work. Read my post #5 above.
Erel B4X founder Staff member Licensed User Longtime User Dec 30, 2020 #11 AnandGupta said: So, Lucas can put the 'wait for' in his class itself (maybe with some parameter) and compiler will work. No need for 'wait for' in calling program . Click to expand... Nope. The developer must call the resumable sub with Wait For, otherwise the developer code will not wait for the class method to complete. As I said, you must use Wait For if you want the execution to wait for something. There is no other (good) option. Cableguy said: So this means that no other language that targets Android has this feature ?? Click to expand... .Net - Xamarin includes a similar feature (async / await). It is not exactly the same and it doesn't work with events. Upvote 0
AnandGupta said: So, Lucas can put the 'wait for' in his class itself (maybe with some parameter) and compiler will work. No need for 'wait for' in calling program . Click to expand... Nope. The developer must call the resumable sub with Wait For, otherwise the developer code will not wait for the class method to complete. As I said, you must use Wait For if you want the execution to wait for something. There is no other (good) option. Cableguy said: So this means that no other language that targets Android has this feature ?? Click to expand... .Net - Xamarin includes a similar feature (async / await). It is not exactly the same and it doesn't work with events.
agraham Expert Licensed User Longtime User Dec 30, 2020 #12 Cableguy said: So this means that no other language that targets Android has this feature ?? Click to expand... Xamarin (C#) has a similar await statement but the impementation is totally different as C# has the ability to save and resume executiom contexts whereas (as far as I know) Java doesn't. Upvote 0
Cableguy said: So this means that no other language that targets Android has this feature ?? Click to expand... Xamarin (C#) has a similar await statement but the impementation is totally different as C# has the ability to save and resume executiom contexts whereas (as far as I know) Java doesn't.