Solved

delay starting a thread until a previous thread is completed

Posted on 2004-08-27
2
163 Views
Last Modified: 2010-05-18
HOw can I delay the start of a thread until a previous thread has completed. My code is as follows:

 Dim Q As Thread
             Q = New Thread(AddressOf invtransfer)
             Q.Name = "putaways_one"
             Q.Start()

            dim R as Thread
            r = new Thread ( AddressOf of runsql)
            r.Name = "putaways_two"
             r.Start()

I want thread R to start after thread Q has exited.  Should I use a Do while loop until status of threadQ is complete?
0
Comment
Question by:fidman
  • 2
2 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11921446
Here is one way:

    Dim Q As Thread
    Q = New Thread(AddressOf invtransfer)
    Q.Name = "putaways_one"
    Q.Start()

    Q.Join() ' Block calling thread until Q has finished

    dim R as Thread
    r = new Thread ( AddressOf of runsql)
    r.Name = "putaways_two"
    r.Start()

Regards,

Idle_Mind
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 11921448
Just a thought though...

If you make your code block with either the Join() method as I have, or a Do...While loop as you propose, why use a thread in the first place?

Idle_Mind
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Javascript Refresh Parent Page from Popup 3 48
Getfiles in vb.net 28 42
More on Time zones in vb 2010 12 37
I need help making a collection from a class in VB.Net 3 23
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now