1

I start a thread in my main form and inside it I call a module, inside that module, I process some files, after each file, I call:

MainForm.IncreaseProgressBar

which is:

Public Delegate Sub IncreaseProgressBarCallback()
Public Sub IncreaseProgressBar()
If MAPIProgressBarX.InvokeRequired Then
   Invoke(Sub() MAPIProgressBarX.Value = MAPIProgressBarX.Value + 1)
Else
   MAPIProgressBarX.Value = MAPIProgressBarX.Value + 1
End If
End Sub

Simply does not work and progress bar won't go through! Any workaround? :( Using vb.NET 4.0

  • 1
    https://stackoverflow.com/a/4699360/17034 – Hans Passant May 17 '23 at 15:17
  • Do not use the c# tag if you are writing in vb.Net. They are different languages. – JonasH May 17 '23 at 15:18
  • I recommend you use `Increment(1)` instead of incrementing the value manually. If you know how many steps there will be then you should also set `Maximum` to that number, so the progress bar makes sense. I don't know if setting the value directly is causing your problem. – Michael Foster May 17 '23 at 15:28
  • You can use the Invoke method directly on the control e.g. MAPIProgressBarX.Invoke(Sub() MAPIProgressBarX.Increment(1)) – Julian May 18 '23 at 13:36

0 Answers0