Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.4k views
in .NET FTP by (120 points)
Hello,
I'm using edFTP in a multithread console application. It works fine with multiple clients and multiple servers.
My problem is I'm tring to use CanceTransfer and ResumeTransfer but i don't understand how it works.
I have an Download object for each download in a separate thread with a FTPConnection object for each one.
When i cancel a download from the thread creator process (my download manager) the download is canceled and
thread execution continues.
Then, how can i to resume transfer using ResumeTransfer instruction?

This is only an example (the code is resumed):
Class Download_manager
{
   //more code ...
   
   public Download[] Downloads;  //Download objets array
   
   public void executeDownloads()
   {
       for (int i = 0; i < nDownloads; i++)
       {
           Downloads[i].objThread = new Thread(new ThreadStart(Downloads[i].initDownload));
           Downloads[i].objThread.Start();
       }
   }
   
   //more code ...   
}

Class Download
{

   //more code ...   

   private FTPConnection ftpConnection1;

   public Download()
        { 
           ftpConnection1 = new FTPConnection();
        }
     
   public initDownload()
   {
      ftpConnection1.ServerAddress = myServer;
           ftpConnection1.ServerPort = myPort;
           ftpConnection1.UserName = myUser; 
           ftpConnection1.Password = myPassword;
           ftpConnection1.TransferType = FTPTransferType.BINARY;
           
           ftpConnection1.DownloadFile(myLocalPath, myRemotefile);
   }
                
   public void pauseDownload()
   {  
       if (ftpConnection1.IsTransferring)
           ftpConnection1.CancelTransfer();
   }
   
   public void resumeDownload()
   {
       if (ftpConnection1.IsConnected)
          ftpConnection1.ResumeTransfer();
   }
               
   //more code ...   
}


someplace in my main code:

//more code ...   

objDonwloadManager.executeDownloads;

objDonwloadManager.Downloads[0].pauseDownload;  //Stop download, thread code continues.
objDonwloadManager.Downloads[0].resumeDownload; //Nothing ocurrs

//more code ...   


Can someone help me? Thanks

1 Answer

0 votes
by (162k points)
ResumeTransfer sets the state so that the next transfer is resumed. It doesn't actually start the transfer itself. You will need to call Get or Put.

Categories

...