Android Question Problem Using a Class

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi, by Erel advice I move my code to a Class.
This code reads an html page and update sql records.
I need to callit from many project activities but I need the class job to be completed until continue.

If I code:

Dim s as NtSyncro (my class)
s.initialize 'init the class
s.wNtSyncro(0,0) 'call the method
log("back from class")
DoUpdateList 'refresh a list
log("back from refresh")

I get in the log:

back from class
back from refresh
wNtSyncro log lines

Then the list is not refreshed

How to do it?

Please see atached image.
 

Attachments

  • 2018-12-07_1235.png
    2018-12-07_1235.png
    66.3 KB · Views: 108

walterf25

Expert
Licensed User
Longtime User
Hi, by Erel advice I move my code to a Class.
This code reads an html page and update sql records.
I need to callit from many project activities but I need the class job to be completed until continue.

If I code:

Dim s as NtSyncro (my class)
s.initialize 'init the class
s.wNtSyncro(0,0) 'call the method
log("back from class")
DoUpdateList 'refresh a list
log("back from refresh")

I get in the log:

back from class
back from refresh
wNtSyncro log lines

Then the list is not refreshed

How to do it?

Please see atached image.
Where is your code for the DoUpdateList, are you using the native ListView or are you using the CustomListView class?


Walter
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Im using CustomListView but it is not the problem.
The problem is that the activity does not wait for the s.wNtSyncro to finish.
The wNtSyncro logs must be before the log("back from class") and not after.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Im using CustomListView but it is not the problem.
The problem is that the activity does not wait for the s.wNtSyncro to finish.
The wNtSyncro logs must be before the log("back from class") and not after.
You should use Wait For.

Walter
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
How to use it? Ive found example on Http and Sql
How to use it with a class metrhod?

Dim s as NtSyncro (my class)
s.initialize 'init the class

wait for (s.wNtSyncro(0,0)) '?????

log("back from class")
DoUpdateList 'refresh a list
log("back from refresh")

Thanks
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Thanks! but it does not worked

s.Initialize
Log("### wait...")
wait for (s.wNtSyncro(0,0)) Complete (result As Boolean)
Log("### back from wait...")
DoUpdateList
Log("### back from DoUpdateList...")

the ### wait...
appears in the log
then all the wNtSyncro logs
and then nothing!
It neves runs ### back from wait !
 
Last edited:
Upvote 0

Brandsum

Well-Known Member
Licensed User
Thanks! but it does not worked

s.Initialize
Log("### wait...")
wait for (s.wNtSyncro(0,0)) Complete (result As Boolean)
Log("### back from wait...")
DoUpdateList
Log("### back from DoUpdateList...")

the ### wait...
appears in the log
then all the wNtSyncro logs
and then nothing!
It neves runs ### back from wait !
You have to return some value from wNtSyncro and declare that sub as ResumableSub. You can return true at the end of the sub to test your code.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I have version 7.01 and when I use ResumableSub I get an error:

Unknown type
Are you missing a library reference?
According to the first line of the first post in the thread that Walter gave you the link to:

Starting from B4A v7.30, B4J V5.90 and B4i V4.30 it is possible to return values from resumable subs.

Looks like you might need a later version of B4A...

- Colin.
 
Upvote 0
Top