Android Question Wait For - sender filter does not work in all circumstances

JackKirk

Well-Known Member
Licensed User
Longtime User
This works:
B4X:
        'Download new control file
    Obj_FTPClient.DownloadFile("X\" & wrk_phn_imei & ".txt", False, File.DirInternal, "scenes2_control.txt")
  
    'Wait for download to complete...
    Wait For Event_obj_ftpclient_DownloadCompleted(ServerPath As String, Download_success As Boolean)

but this does not:
B4X:
        'Download new control file
    Obj_FTPClient.DownloadFile("X\" & wrk_phn_imei & ".txt", False, File.DirInternal, "scenes2_control.txt")
  
    'Wait for download to complete...
    Wait For (Obj_FTPClient) Event_obj_ftpclient_DownloadCompleted(ServerPath As String, Download_success As Boolean)

Obj_FTPClient is declared as:

Private Obj_FTPClient As FTP

in Process_Globals.

Anyone have any clues?
 

Ed Brown

Active Member
Licensed User
Longtime User
Are you attempting to download more than a single file at a time? If yes, then you will need to create a new instance of the FTP object for each download.
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Ed, thanks for your response.

No, I'm doing a single download/upload at a time.

I think the weirdo I have discovered is something to do with the Obj_FTPClient having to be global but would like it confirmed - and explained if possible.
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel,

I spent several hours banging at this.

For everyone's information it would be good to know what other current anomalies there are with using the sender filter parameter.

PS: I am in love with wait for...

PPS: I updated the thread title to be more relevant to others.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
anomalies there are with using the sender filter parameter
It is not really related to sender filter. It is related to the Net library not setting the Sender itself when raising the event. As I wrote it will be fixed (the methods will return an object that you can use as the sender filter).
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
OK, I'll rephrase: in what other circumstances can't the sender filter be used.

I'm not being a PITA, wait for is a great feature that shouldn't be clouded by issues like this.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm not familiar with any other library that raises an event without setting the sender parameter. It doesn't mean that there aren't. In the past the sender parameter was less important in some cases.

If you have any doubt then:

- Use Wait For without the sender filter parameter. The sender filter is only important when there are multiple objects that raise the same event.
- Or check it yourself by handling the event and testing the output of Log(Sender) to see whether the sender is set or not.
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
I'm not familiar with any other library that raises an event without setting the sender parameter
Trust me to tread on the only broken glass on the beach...
 
Upvote 0
Top