VB project is migrated to VB.NET. In that I am facing one issue.
Need to upload the configuration file to the device. For that, in the Background_DoWork, we are initializing the form which contains progressbar and then
AddHandler Me.webClient.UploadProgressChanged, AddressOf Me.UpdateProgressBar
is provided.
In the UpdateProgressBar method, we are incrementing the progress bar value.
But I am not able to see the progress bar. Hope UploadProgressChanged event is not triggering.
Anybody could help me to resolve this is appreciated.
Code for the above issue is as below
Public
Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim isTimerCreated As Boolean = True
If (frmTimer1 Is Nothing) Then
isTimerCreated =
False
ElseIf (frmTimer1.IsDisposed) Then
isTimerCreated =
False
End If
If (Not isTimerCreated) Then
frmTimer1 =
New frmTimer()
Dim handle As IntPtr = frmTimer1.Handle
frmTimer1.Timer1.Enabled =
True
frmTimer1.Timer1.Start()
frmTimer1.Show()
End If
AddHandler
Me.webClient.UploadProgressChanged, AddressOf Me.UpdateProgressBar
Me.isUploaded = Me.FtpFileTransfer(strFullFilePath, "PUT")
frmTimer1.Timer1.Stop()
frmTimer1.Close()
End Sub
Public Sub UpdateProgressBar(ByVal sender As Object, ByVal e As System.Net.UploadFileCompletedEventArgs)
Try
Dim realProgress As Integer
If frmTimer1.ProgressBar1.InvokeRequired Then
frmTimer1.ProgressBar1.Invoke(
New UploadFileCompletedEventHandler(AddressOf UpdateProgressBar), sender, e)
Exit Sub
End If
frmTimer1.ProgressBar1.Value =
CInt(frmTimer1.Min + ((frmTimer1.Max - frmTimer1.Min) * realProgress) / 100)
Catch ex As WebException
If ex.Status = WebExceptionStatus.SendFailure Then
MsgBox(
"FTPServer connection failure" & strCrLf & "Upload Aborted", MsgBoxStyle.Exclamation)
'FtpFileUpLoad = False
Exit Sub
End If
End Try
End Sub