Hi, I'm newbie here.
Can anybody help me to use
progressbar with backgroundworker properly?
I did research but I always failed maybe I can find the answer in your comment.
You can
comment
in German I used
the code from this post:Backgroundworker and Progressbar
My
problem is the result is
Not 100% but it's not accurate result
Here's the code
that I've been using
[code]Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Label6.Text = e.UserState.ToString
End Sub
Can anybody help me to use
progressbar with backgroundworker properly?
I did research but I always failed maybe I can find the answer in your comment.
You can
comment
in German I used
the code from this post:Backgroundworker and Progressbar
My
problem is the result is
Not 100% but it's not accurate result
Here's the code
that I've been using
Quellcode
- Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
- Dim folder As String = txtSource.Text
- Dim encryptionKey As Byte() = File.ReadAllBytes(txtKey.Text)
- Dim outputFile As String = (txtFilePath.Text + "" + txtFileName.Text + ".ts")
- Using outputFileStream As File FileStream = New FileStream(outputFile, FileMode.Create)
- Dim files = Directory.GetFiles(folder, "*.ts")
- For i As Integer = 0 To files. Length - 1
- Dim encryptionIV As Byte() = New Byte(15) {}
- Using inputFileStream As FileStream = New FileStream(files(i), FileMode.Open)
- Using aes = New AesManaged With {
- .Key = encryptionKey,
- .IV = encryptionIV,
- .Mode = CipherMode.CBC
- }-
- Using encryptor = aes. CreateDecryptor()
- Using cryptoStream = New CryptoStream(inputFileStream, encryptor,CryptoStreamMode.Read)
- '''BACKGROUNDWORKER START
- Application.DoEvents()
- Dim p As Long
- For x As Integer = 0 To 100
- p += 1
- Next
- BackgroundWorker1.ReportProgress(100, p)
- ''''BACKGROUNDWORKER END
- cryptoStream.CopyTo(outputFileStream)
- End Using
- End Using
- End Using
- End Using Next
- End Using End Sub
[code]Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Label6.Text = e.UserState.ToString
End Sub
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „zackmark29“ ()