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

Wait for thead before executing function

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
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…

856 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