Solved

Wait for thead before executing function

Posted on 2006-07-13
5
164 Views
Last Modified: 2010-04-23
How can I wait for the thread "thread" to execute and finish before calling GETEPP?

Do while thread.stopped = false
application.doevents
loop


doesn't seem to work.


 Public Sub New(ByVal url As String, ByVal DTable As DataTable, ByVal EventCode As String, ByVal Agent As String, ByVal EventInstance As String, ByVal tabC As TabControl, ByVal thegoahead As String)
            m_url = url

         Dim thread As New Threading.Thread(AddressOf StartGetDocument)
            thread.Name = "StartGetDocument"
            thread.Start()

              GetEPP(m_document, DTable, tabC, EventCode, EventInstance, Agent, thegoahead)

        End Sub
0
Comment
Question by:JPERKS1985
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
Nandakumar Sakthivel earned 500 total points
ID: 17105839
Hi,
   why don't you put
                   GetEPP(m_document, DTable, tabC, EventCode, EventInstance, Agent, thegoahead)
   as a last staement in the StartGetDocument) function.it will work for your case

Thanks,
Nanda
0
 
LVL 1

Author Comment

by:JPERKS1985
ID: 17105844
I'd have to pass all those parameters i already tried it and I was getting alot of errors.
0
 
LVL 1

Author Comment

by:JPERKS1985
ID: 17105851
I'm not sure what the problem is, ive been trying to find the bug for a week now, I'm thinking its a threading issue, the first time I run the thread it works then second time it messes up.
0
 
LVL 1

Author Comment

by:JPERKS1985
ID: 17105876
Fixed it! I took out the startgetdocument thread and just put its code in there. Thanks for your help!
0
 
LVL 6

Expert Comment

by:Nandakumar Sakthivel
ID: 17105894
Hi,
   Include some thing like this

                   thread.Name = "StartGetDocument"
                   thread.Start()
                  -->thread.join()
                   GetEPP(m_document, DTable, tabC, EventCode, EventInstance, Agent, thegoahead)

Include thread.join() method as specified above.This will block the main thread until the child thread that you are creating finishes

Thanks,
Nanda
     
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

12 Experts available now in Live!

Get 1:1 Help Now