0 votes
by (900 points)

I have a situation where i need to automatically upload files. if ftp is busy then i am adding upload requests in a queue otherwise i am directly uploading files. now i need an event which notifies that ftp is free to upload items in my upload queue.

Currently i am using statechanged event but it is not too reliable because whenever ftp.state changes to Ready state, ftp.IsBusy property does not get set to false.

if i try to upload file when ftp state changes to ready state, it throws another operation pending exception because ftp is still busy.

Is there any workaround to handle this situation ?

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (58.9k points)

The recommended and most reliable way is to wait until the current method (be it sync or async) finishes and only when it has finished then call another method. So when you start an operation and you have another request when the operation is still in progress, just put the new requests into some queue and only continue executing the new requests after the original operation has ended.

If you want to call more methods at once, it is possible to set Ftp.Settings.EnableMultipleBlockingCalls to 'true'.

please note that this is really unrecommended as it will be very inefficient.

Ftp.State is property is a relict from the times when there was no log in the Ftp class. This property returns the state on the level of FTP protocol, not on the FTP component level! So ftp.State can change multiple times within one call of a Ftp class method. So definitely do not use the Ftp.State as it is planned to be deprecated soon.

...