By default, asynchronous operations started by methods (such as BeginConnect
or BeginPutFile
) never time out and the value of Ftp
object's Timeout
property doesn't affect them. But when the TimeoutAsynchronousMethods
option is enabled, they time out just like synchronous methods (such as Connect
or PutFile
).
When an asynchronous method times out, an FtpException
with Status
of FtpExceptionStatus.Timeout
is thrown. This is similar to other kind of errors. The asynchronous operations ends immediately, which means the callback gets called. The exception is thrown as soon as you can the End*
method (such as EndConnect
or EndPutFile
).
Please note that the Timeout
value doesn't specify the maximum time allowed for the whole operation. Instead, the operation times out when no response has been received for the specified amount of time.
You can specify multiple options, but you have to use bitwise | instead of &:
// Set client options
client.Options = Rebex.Net.FtpOptions.TimeoutAsynchronousMethods |
Rebex.Net.FtpOptions.KeepAliveDuringTransfer |
Rebex.Net.FtpOptions.UseLargeBuffers |
Rebex.Net.FtpOptions.DisableProgressPercentage;
Using the &
operator would be equivalent to client.Options = 0;
and no flags would be set. For detailed explanation, check out this link.