I am getting the following error when the AsyncCallback Method is called after the method SFtp.BeginPutFile has finished uploading the file. I would like to call a fixed number of threaded uploads and have the AsyncCallback method called when each one has completed.
The IAsyncResult object returned from the UploadComplete method does show the _result variable with the size of the file that was successfully uploaded when I inspect the variable n Visual Studio.
System.ArgumentException was caught
Message=The IAsyncResult object supplied to GetFileInternal was not returned from the corresponding GetFileInternal method on this class.
Parameter name: asyncResult
at Rebex.Net.Sftp.EndAsync(IAsyncResult asyncResult, MethodBase method) in c:\Data\Build\WorkingDirectory\Rebex.AllPackages\output\Sftp\dist\input\sc\Sftp\Sftp.cs:line 377
at Rebex.Net.Sftp.EndGetFile(IAsyncResult asyncResult) in c:\Data\Build\WorkingDirectory\Rebex.AllPackages\output\Sftp\dist\input\sc\Sftp\Sftp.cs:line 2996
at SFTP_Backup.frmMain.UploadComplete(IAsyncResult asyncResult) in C:\Projects2010\SFTP Backup\SFTP Backup\WinForms\frmMain.vb:line 660
Private Sub cmdStartThreading_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStartThreading.Click
' Begin Asynchronous Transfer
Dim asyncResult As IAsyncResult
asyncResult = ftp.BeginPutFile("C:\Reports\File1.txt", "/File1.txt", New AsyncCallback(AddressOf UploadComplete), Nothing)
Private Sub UploadComplete(ByVal asyncResult As IAsyncResult)
' get the result
Dim bytes As Long
' Error occurs on the next line
bytes = ftp.EndGetFile(asyncResult)
Catch ex As Exception
Log.Error(ex, System.Reflection.MethodInfo.GetCurrentMethod.Name, "Error", ex.ToString, "")