Problem in thread

Sani Love 160 Reputation points
2023-05-17T14:29:37.9+00:00

Hi

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? :(

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,205 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,564 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,031 Reputation points
    2023-05-17T15:19:39.5066667+00:00

    Consider looking at IProgress<T> using Report method. Check out a basic example here.


  2. Jiachen Li-MSFT 26,426 Reputation points Microsoft Vendor
    2023-05-25T02:26:40.3166667+00:00

    Hi @Sani Love , Try the following code to see if it helps.

    MainForm.Invoke(New IncreaseProgressBarCallback(AddressOf MainForm.IncreaseProgressBar))

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments