I have the following code which starts a download:
_transferClient = new Ftp { Timeout = -1 };
_transferClient.Options |= FtpOptions.KeepAliveDuringTransfer;
_transferClient.Connect(SessionSettings.Server);
_transferClient.Login(SessionSettings.Username, SessionSettings.Password);
_transferClient.GetFile(RemotePath, LocalPath);
Then, in a button event handler, I have this code which attempts to cancel the upload, disconnect, then dispose the Ftp object
_transferClient.Abort();
_transferClient.Disconnect();
_transferClient.Dispose();
_transferClient = null;
What is the correct way to do this without receiving the "Another operation is pending" exception?