Previously I was using a new thread, but I decided to try a background worker, but still no luck.
What is happening is I click the button and the progress bar stays at 0% until my time consuming (10 seconds) for loop is finished, and then the progress jumps to 100% Any help is appreciated, thanks in advance.
Here on Windows 7, it has a nice animated gradient, as seen on the screenshot.
I have all my code in a module which i want to access from the main ui. Any sample code that shows how to use BGW tells you to use e. Do not use Invoke Required, the point of the Progress Changed event is that you don't have to. Do Work For i As Integer = 1 To 100 Background Worker1. I start the backgroundworker from the mainform and call my procedures for the module which needs to report back to the mainforms ui (Progressbar). Value = CInt(PBar) End Sub Private Sub Background Worker_Run Worker Completed(By Val sender As Object, _ By Val e As System. Run Worker Completed Event Args) _ Handles Background Worker. Cancelled = True Then Alert(Me, "Canceled", "The process has been canceled.", Message Box Buttons. Do not call Report Progress() too often, you can fire-hose the UI thread with too many updates. The pattern is pretty simple so I suggest you break it down and find out where the issue is. Run Worker Async() End Sub Private Sub Background Worker1_Do Work(sender As Object, e As System. PBar is a public intreger that counts as the progress count for the Progress bar. Do Work Pastel GRNS(0) Pastel RTS(0) Pastel INVS(0) Pastel CRNS(0) End Sub Private Sub Background Worker_Progress Changed(By Val sender As Object, By Val e As System. Progress Changed Event Args) Handles Background Worker. Do not use a type name like "Main Menu" in a worker thread, that will create a new instance of the form that you cannot see. Avoid using a global variable to hold the percentage, this should just be passed in when you call Private Sub Form1_Load(sender As Object, e As Event Args) Handles My Base. The code that I'm working with looks like this: Protected Overrides Sub On Load(By Val e As System. Object, By Val e As Do Work Event Args) Handles Background Worker1. Do Work Dim logfile = "C:\ex111124.log" Dim File Length As Long = New System. I have a WPF form containing a button and a progress bar element.