0

i have an async upload task.Into that upload function :

 AddHandler fileTransferUtilityRequest.UploadProgressEvent,
                    Sub(sender As Object, e As UploadProgressArgs)
                        ProgressForm.CPBar1.Value = 0
                        Dim percent As Integer = convert.toint32(e.transferredbytes) 'e.transferredbytes as long 
                        myProgress = New Progress(Of Integer)(AddressOf ReportProgress)
                        myProgress.Report(percent)

                    End Sub

actually the progressbar1.maximum=convert.toint32(sizeofupload) and the progressbar1.minimum=0 ofcourse, sizeofupload variable's type is as long

then about theReportProgress is,

Public Sub ReportProgress(ByVal myInt As Integer)
        ProgressForm.CPBar1.Value = myInt
    End Sub

i have converted all long type values in int32 type. but,it does n't worked. the error shows value should be between maximum and minimum.! i want to progress the transferred bytes in my progress bar while uploading.e.transferredbytes as long variable had the transferredbytes value. so,can anyone knows what i'm missed?

KR32
  • 381
  • 5
  • 10
  • First things first, what type is `fileTransferUtilityRequest` and is that event raised on the UI thread? – jmcilhinney May 21 '20 at 07:42
  • @jmcilhinney => [Async, Await EventHandler return value](https://stackoverflow.com/q/61833424/7444103) – Jimi May 21 '20 at 08:20
  • 1
    Keep the ProgressForm.Maximum as `100` and remove `ProgressForm.CPBar1.Value = 0` from the Lambda. -- Since you know the file size beforehand (you're uploading it), divide the size by `100` and update the UI when you have uploaded a multiple of the calculated chunk. If you also want to show the number of bytes transferred, show this information in another control, a Label maybe. This: `myProgress = New Progress(Of Integer)(AddressOf ReportProgress)` is completely wrong. You don't add a handler each time you need to report progress, you do that just once, when you create a `Progress` object. – Jimi May 21 '20 at 08:29

0 Answers0