What is the logic behind the DoneEvent? - WeOnlyDo Discussion board

What is the logic behind the DoneEvent? (wodFtpDLX / wodFtpDLX.NET)

by tonym, Tuesday, October 06, 2015, 06:17 (1812 days ago)

I'm using FtpDLX.Net and just like the other WOD controls I use I love it. It is a vast improvement over the last FTP control I had.

That said, I'm a but puzzled by the use of the DoneEvent that is called for multiple methods such as LisrDir, PutFile, GetFile and so on. It seems to be counter-productive. For example:

I want to issue a

ftp1.RemotePath = path
ftp1.PutFile(LocalPath, RemotePath)

in that order. The problem is that as soon as the ftp1.MakeDir is issued it immediately tries to issue the ftp1.RemotePath and then the ftp1.PutFile, all before MakeDir is completed. Now, I know that after I issue the MakeDir I'm supposed to wait for the DoneEvent to fire before issuing the RemotePath but I have no idea how to "pause" execution until the DoneEvent fires. What I end up with is having to put RemotePath and PutFile in the DoneEvent as well as for the ListDir and so on.

Surely there is a better way to do this. I wish these methods were synchronous so that when one is issued the program would wait for it to complete before proceeding.

Any suggestions?

What is the logic behind the DoneEvent?

by Jasmine, Tuesday, October 06, 2015, 08:21 (1812 days ago) @ tonym

Hi Tony.

Your code should be state driven. You can have your own enumeration of states like

MyState = {SomethingBefore, MakingDirectory, UploadingFile, SomethingAfter....}

and then in Done do

if MyState == SomethingBefore
MyState = MakingDirectory
if MyState == MakingDirectory
MyState = UploadingFile
Ftp1.PutFile (local, remote)
if MyState == UploadingFile
MyState = SomethingAfter
Ftp1.Do Something.

so, you end up always in Done, but your 'MyState' variable decides which command to execute.

I hope this helps!