Solved

delay starting a thread until a previous thread is completed

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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