Solved

Wait for thead before executing function

Posted on 2006-07-13
5
200 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

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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