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
Solved

delay starting a thread until a previous thread is completed

Posted on 2004-08-27
2
166 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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