Android Question Convert MsgBox to MsgBoxAsync

Creideiki

Active Member
Licensed User
Longtime User
Hi there,

I am trying to convert many MsgBoxes to MsgBoxAsync. Since my App uses very much of them in different variants, that will be a lengthy task. I can't often simply use the *Async without Wait For, since often there are more than one Box in a row in one context. And when I don't Wait For, they come in the wrong sequence.

My actual problem is:
I have a sub in a code module which checks a value, which is called by two different activities. This sub tells the user about the result and returns a boolean value for the calling activity.
Now I can't use Wait For in a code sub. I can't move the sub in one of the activity modules, since the other can't call it directly. I can't simply return the text as string, since I have to return the boolean.

One possibility would be to copy the sub in both activities, but I don't want to do that, it would by risky when something changes with the check.

What's the best way to solve that?
 

Lucas Siqueira

Active Member
Licensed User
Longtime User
Hi there,

I am trying to convert many MsgBoxes to MsgBoxAsync. Since my App uses very much of them in different variants, that will be a lengthy task. I can't often simply use the *Async without Wait For, since often there are more than one Box in a row in one context. And when I don't Wait For, they come in the wrong sequence.

My actual problem is:
I have a sub in a code module which checks a value, which is called by two different activities. This sub tells the user about the result and returns a boolean value for the calling activity.
Now I can't use Wait For in a code sub. I can't move the sub in one of the activity modules, since the other can't call it directly. I can't simply return the text as string, since I have to return the boolean.

One possibility would be to copy the sub in both activities, but I don't want to do that, it would by risky when something changes with the check.

What's the best way to solve that?

check this link, there are two examples, I believe it is what you are looking for.

https://www.b4x.com/android/forum/t...odule-by-passing-the-calling-activity.114981/ # post-718425
 
Upvote 0

Creideiki

Active Member
Licensed User
Longtime User
So I really should replace the code modules with classes, shouldn't I?

That means I have to create an instance each time I need one.

Well... that's more extra complexity either.

I have to replace each MsgBox by
B4X:
MsgBoxAsync(...)
Wait For MsgBox_Result (...)
not only in the sub with the MsgBox but in each calling sub, because I have to make them ResumabeSubs most of the time.

I like classes, I have converted many parts of the app to classes since I took over the development... But there are some parts which generate more complexity as necessary in my opinion, e.g. the lack of static methods in classes or the handling of async messageboxes.

Anyway, thanks for the answer, I will try to replace the code modules by classes.
 
Upvote 0
Top