troubleshooting Question

Check for Finished Threads

Avatar of slightlyoff
slightlyoff asked on
Visual Basic.NET
4 Comments1 Solution224 ViewsLast Modified:
I run several Threads to check values in a database.  When a thread is finished it writes back to its own label on the form.  When all threads are finished, I would like to add the total of all those labels.

Not sure how to do that - how to tell when each is done.

I've attached the code for one function (one thread)... the only difference between this one and the others is the goc.GetConnection variable and the goc.theTextBox.

Thanks for your help!
getHendersons()
        getMidwest()
        getGreat()
        getBand()

        TotalOrders.Text = CInt(hOrderCount.Text) + CInt(mOrderCount.Text) + CInt(gOrderCount.Text) + CInt(pOrderCount.Text)



Public Sub getHendersons()
        lblHendersons.ForeColor = Color.White
        Dim goc As New GetOrderArgs
        goc.getConnection = HendersonConnectionString
        goc.theTextBox = Me.hOrderCount
        goc.startDelegate = AddressOf GetOrderCount
        Dim t As New Thread(AddressOf goc.StartConnection)
        threadCount += 1
        t.Name = "Thread " & threadCount.ToString()
        t.IsBackground = True
        t.Start()
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros