Hi,

How do I run a form that has a progress bar on a separate thread from another form?

Thanks

Add following code in second Form (say Form2) in which ProgressBar control was added.

Public Class Form2

    Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim tst As New Action(AddressOf Test)
        ProgressBar1.BeginInvoke(tst)
    End Sub
    Sub Test()
        For i As Integer = 1 To 100
            ProgressBar1.Value = i
            Threading.Thread.Sleep(100)
            ProgressBar1.Refresh()
        Next
    End Sub
End Class
commented: Action. Awesome. I can now do away with my "GenericDelegate" I usually create. +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.