?
Solved

delay starting a thread until a previous thread is completed

Posted on 2004-08-27
2
Medium Priority
?
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

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 86

Accepted Solution

by:
Mike Tomlinson earned 375 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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