Android Question Wait For (<sender>) ... with callsub/callsubdelayed indirectly

b4auser1

Well-Known Member
Licensed User
Longtime User
B4X:
Private Sub Msgbox_Click(ButtonText As String)
    bCallSubUtils.WithAppExit3_IfSubNotExistsX("clsB_Msgbox3", "Msgbox_Click", "CallbackModule", Subname, CallbackModule, ButtonText, UserData, True)
'    CallSubDelayed3(CallbackModule, Subname, ButtonText, UserData)
End Sub

With CallSubDelayed3 ... wait for (sender) works.
With bCallSubUtils.WithAppExit3_IfSubNotExistsX wait for (sender) doesn't work.
With bCallSubUtils.WithAppExit3_IfSubNotExistsX wait for without (sender) works.

bCallSubUtils - helper code module with sub wrappers for callsub/callsubdelayed routines.
 

b4auser1

Well-Known Member
Licensed User
Longtime User
I do different checks (that I need) in the code module.

I stripped my checks. Try this Sub wrapper to emit event and you will see, that wait for with sender doesn't work.

B4X:
Public Sub CallSubDelayed3W(CallbackModule As Object, Subname As String, Argument1 As Object, Argument2 As Object)
    CallSubDelayed3(CallbackModule, Subname, Argument1, Argument2)
End Sub
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
Ok. Let's sort out.

Dim VarFilter As cls_Msgbox3 is in sub in class module.
In the class module there is call of sub in cls_Msgbox3.
Then in cls_Msgbox3 class module there is a call of sub in bCallSubUtils code module.
Sub in the code module uses callsub/callsubdelayed to call callback sub in original module.
In original module in the sub where VarFilter As cls_Msgbox is declared, there is wait for with filter set to VarFilter.

If I understood you right, in order to fix problem with sender field I need to replace code module that uses callsub/callsubdelayed with class module ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
If I understood you right, in order to fix problem with sender field I need to replace code module that uses callsub/callsubdelayed with class module ?
The sender field will be set in that case to the class instance. Make sure that you are using the same instance as the sender filter parameter.

Note that if you are using the same sender filter instance then the sender filter is not really useful and can be removed.
Each sender filter instance should be different. For example with HttpJob it is recommended to use local HttpJobs. This way they are always unique.
 
Upvote 0
Top