0

I am downloading a file from an ftp usin FLuentFtp. If I call the synchroneous methods:

client.Connect();

var status = client.DownloadFile(localPath, ftpPath);

then it works but the asynchroneous versions namely:

await client.ConnectAsync();

FtpStatus status = client.DownloadFileAsync(localPath, ftpPath).Result;

both don't work. Neither throw an exception but they don't complete within 2 minutes where the synchroneous versions take 2 seconds.

Could it be that there isn't a thread available to run these methods, and if so how can I check this.

The TaskState is WaitingForActivation if that helps narrow things down.

Backs
  • 24,430
  • 5
  • 58
  • 85
G Aker
  • 109
  • 4

1 Answers1

0

I think, you have a deadlock in line:

client.DownloadFileAsync(localPath, ftpPath).Result;

You should call it with await:

FtpStatus status = await client.DownloadFileAsync(localPath, ftpPath);
Backs
  • 24,430
  • 5
  • 58
  • 85
  • Ok fair point but it doesn't even reach that line when connect is called asynchroneously. I also disagree that it should deadlock but block the thread I agree with. – G Aker Dec 11 '20 at 11:54
  • Actually I tried the solution in the question you linked and it fixed my problem. I can't say Ifully understand why but it is now working – G Aker Dec 11 '20 at 12:10