FTP file download fails on device

willisgt

Active Member
Licensed User
I've written a routine which dowloads files via the FTP library. In order to preserve the ability to update a progress bar during the download, I use the threading library to create a thread which actually downloads the file.

All of this works just fine if compiled for the desktop (optimization is on). However, it fails on the device. I'm getting an error message that an optional resource assembly was not found.

The code for the thread itself is just this simple:
B4X:
Sub threadSyncFile_ThreadCode

   ErrorLabel( threadSyncFile_ThreadCodeError )
   
   ftpSyncFile.GetFile( labelSyncFileSource.Text, labelSyncFileTarget.Text )

   syncSetLastDownload( labelSyncFileSource.Text )
   
threadSyncFile_ThreadCodeError:

   labelSyncFileTarget.Text   = ""
   labelSyncFileTarget.Refresh

   Return

End Sub

I've double-checked, and yes, I've got FTPDevice.DLL installed on the device.

The desktop is running Windows XP Pro; the Basic4PPC version is 6.05; the device is an HTC 8925/AT&T Tilt running Windows Mobile 6.

I've beaten my head against a wall too many times already this week; anyone have any ideas, especially why this works on the desktop, but not the device?

Gary

:sign0085:
 

willisgt

Active Member
Licensed User
A little more insight into the problem...

I commented out these two lines and still got the same error:
B4X:
'   ftpSyncFile.GetFile( labelSyncFileSource.Text, labelSyncFileTarget.Text )

'   syncSetLastDownload( labelSyncFileSource.Text )
And was able to catch a more robust error message:

Not Supported Exception
An error message cannot be displayed because an optional resource assembly containing it cannot be found

at Microsoft.AGL.Common.MISC.HandleARr()
at System.Windows.Forms.Form.Close
at Dbasic.b4p.ShowError()
at Dbasic.b4p._threadsyncfile_threadcode()
at Dbasic.b4p._threadsyncfile_threadcode()
at Threading.Thread.wrapper()

???
 
Last edited:

willisgt

Active Member
Licensed User
Answered my own question

Answer: threads are not GUI-safe.

Don't try to update anything GUI-related (like the text of a label) from within a thread's code.

:signOops:
 

agraham

Expert
Licensed User
Longtime User
Don't try to update anything GUI-related (like the text of a label) from within a thread's code.
It's all documented there in the help and in the comments of the example application. That's why thread events are provided. The example porgram shows a thread updating a textbox using a thread event.

Edit :-The missing resource assembly contains the actual error messages that would give a bit more detail about the error. So the original error cannot be displayed triggering a further missing resource error! See this thread http://www.b4x.com/forum/showthread.php?t=870
 
Last edited:
Top