Delegate issue

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hey,
i have the code below Imports Rebex
Imports Rebex.IO
Imports Rebex.Net
Imports Rebex.Security.Certificates

Public Class Form1

Private FTP As Sftp
Dim ip As String = "IP"
Dim username As String = "username"
Public password As String = "pass"

download common module
Public Sub Download()
Dim remotedir As String = "app/data/123kickit"

Connect()

If Logging.Checked = True Then
FTP.LogWriter = New Rebex.FileLogWriter(currentlog, Rebex.LogLevel.Debug)
End If

Try
SetState(True)
Dim result As IAsyncResult = FTP.BeginDownload(remotedir, Application.StartupPath & "dl/common", TraversalMode.Recursive, TransferMethod.Copy, ActionOnExistingFiles.OverwriteDifferentSize, New AsyncCallback(AddressOf FinishCommonDownload), Nothing)
Catch ex As Exception
Disconnect()
SetState(False)
MsgBox(ex.Message)
Exit Sub
End Try
End Sub

Private Sub FinishCommonDownload(ByVal result As IAsyncResult)
If (Me.InvokeRequired) Then
Me.Invoke(New Action(AddressOf FinishCommonDownload), result)
Exit Sub
End If
dim exes as string = "exes/data/"
Try
If (Me.InvokeRequired) Then
Me.Invoke(New Action(Of Boolean)(AddressOf SetState), New Object() {True})
End If
Dim result2 As IAsyncResult = FTP.BeginDownload(exes, Application.StartupPath & "exes", TraversalMode.Recursive, TransferMethod.Copy, ActionOnExistingFiles.OverwriteDifferentSize, New AsyncCallback(AddressOf FinishDownload), Nothing)
Catch ex As Exception
Disconnect()
SetState(False)
MsgBox(ex.Message)
DialogBoxer.ShowDialog()
Exit Sub
End Try
End Sub


Private Sub FinishDownload(ByVal result2 As IAsyncResult)
Try
FTP.EndDownload(result2)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try

Disconnect()

NotifyIcon.BalloonTipIcon = ToolTipIcon.Info
NotifyIcon.BalloonTipTitle = "Download completed"
NotifyIcon.BalloonTipText = "Your download is now completed" & vbNewLine & "Enjoy :)"
NotifyIcon.ShowBalloonTip(5000)

If (Me.InvokeRequired) Then
Me.Invoke(New Action(Of Boolean)(AddressOf SetState), New Object() {False})
End If
End Sub

Private Sub TransferProgressChanged(ByVal sender As Object, ByVal e As SftpTransferProgressChangedEventArgs)
µProgressBar.Value = e.ProgressPercentage
If µProgressBar.Value = 100 Then
processbtn.Text = " No data!"
processbtn.SideColor = µSideButton._Color.Red
processbtn.DisplayIcon = µSideButton._Icon.Circle
Else
processbtn.Text = " Downloading"
processbtn.SideColor = µSideButton._Color.Green
processbtn.DisplayIcon = µSideButton._Icon.Square
End If
filesprocessed.Text = e.FilesProcessed
speedlbl.Text = ThreeNonZeroDigits(BytesTO(e.BytesPerSecond, convTo.KB)) & " KBs"
currentsize.Text = ThreeNonZeroDigits(BytesTO(e.BytesTransferred, convTo.GB)) & " GB"
End Sub

Private Sub Traversing(ByVal sender As Object, ByVal e As SftpTraversingEventArgs)
totalfiles.Text = e.FilesTotal
gsize.Text = ThreeNonZeroDigits(BytesTO(e.BytesTotal, convTo.GB)) & " GB"
Select Case (e.TraversingState)
Case TraversingState.HierarchyRetrieving
processbtn.Text = "Retrieving hierarchy"
processbtn.SideColor = µSideButton._Color.Yellow
processbtn.DisplayIcon = µSideButton._Icon.Square
Exit Select
End Select
End Sub

Private Function Connect() As Boolean
Try
Cursor = Cursors.WaitCursor

FTP = New Sftp
FTP.Settings.UseLargeBuffers = largebuffers.Checked
FTP.Timeout = 1800000
Dim par As New SshParameters
par.Compression = True

FTP.Connect(ip, 7784, par)
FTP.Login(username, password)

AddHandler FTP.TransferProgressChanged, AddressOf TransferProgressChanged
AddHandler FTP.Traversing, AddressOf Traversing
Return True
Catch x As SftpException
MsgBox(x.Message)
Return False
Finally
Cursor = Cursors.Arrow
End Try
End Function

Private Sub Disconnect()
FTP.Disconnect()
FTP.Dispose()
FTP = Nothing
End Sub

Private Sub SetState(ByVal transferring As Boolean)
status = "Downloading"
Else
status = "Idle"
End If
End Sub

Now I get an error with FinishCommonDownload sub stating
Method Private Sub FinishCommonDownload(result As System.IAsyncResult) does not have a signature compatible with delegate Delegate Sub Action().
any idea on how to fix it?

View the full article
 
Back
Top