hi
i have a class module named > class1
then i creat 10 instance from class1 ( c1 as class1,c2 as class1 ,.......)
Now I want call a sub in class1 and update data for all instance
What can be the fastest and most optimal solution?
The solution I am currently using is that I keep the list of instances and then execute the desired function for each instance as follows.
I think it would be easier and more efficient to use events, but I couldn't do it inside the classes.
Clearly, I want to use events instead of lists (project attached).
In fact, whenever the database is updated, I understand and update the class
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
i have a class module named > class1
then i creat 10 instance from class1 ( c1 as class1,c2 as class1 ,.......)
Now I want call a sub in class1 and update data for all instance
What can be the fastest and most optimal solution?
The solution I am currently using is that I keep the list of instances and then execute the desired function for each instance as follows.
B4X:
dim c1 as class1
dim c2 as class1
.
.
.
.
Dim list1 As List
list1.Initialize
list1.AddAll(Array As object(c1,c2,.....))
For Each c As class1 In list1
c.mysub
Next
I think it would be easier and more efficient to use events, but I couldn't do it inside the classes.
Clearly, I want to use events instead of lists (project attached).
In fact, whenever the database is updated, I understand and update the class
B4X:
'form1
'database updated
If SubExists(class1,"mysub") Then
CallSubDelayed2(class1, mysub, myparams)
EndIf
B4X:
'class1
sub mysub(object param0)
'any code
end sub
Attachments
Last edited: