I wrote a program which is checking for mails. It is comparing the mails with a list in Excel. If the mail was found in the list as well, it is moving them.
I did include a Progress-bar Control in the program, and it is working. But not as it should be. Once the program moved all the mails, the Progress-bar Control starts to move.
After a lot of research I found out, that it's not possible to interact with the GUI. I need to 'stop' my Code first. I tried that, But none of the solutions I found did work out for me.
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, _
ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'Do
'Percentage = Count / (Anzahl_mail + 1)
'Percentage = Percentage * 100
Dim numToDo As Integer = CInt(e.Argument)
For n As Integer = 1 To numToDo
System.Threading.Thread.Sleep(100)
BackgroundWorker1.ReportProgress(Convert.ToInt32((n / numToDo) * 100))
'BackgroundWorker1.ReportProgress(Percentage)
Next
'Loop While Not BackgroundWorker1.CancellationPending
End Sub
Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, _
e As System.ComponentModel.ProgressChangedEventArgs) _
Handles BackgroundWorker1.ProgressChanged
If ProgressBar1.Value = ProgressBar1.Maximum Then
ProgressBar1.Value = ProgressBar1.Minimum
End If
Me.ProgressBar1.Value = DirectCast(e.ProgressPercentage, Integer)
'Me.Invoke(New MethodInvoker(Sub() Me.ProgressBar1.Value = e.ProgressPercentage))
End Sub