i have a function that contains the following
WebUpdateThread = New System.Threading.Thread(AddressOf generatecids)
WebUpdateThread.SetApartmentState(ApartmentState.STA)
WebUpdateThread.Start()
'after starting the thread i have some code that i want to run when the thread finshes its work which takes about 3-4 hours
'if i put for example
MsgBox("something")
the message box shows as soon as the thread starts, how do i make it wait until the thread is finshed?
is there something more sufficient than an infitine while loop that checks the thread state?
You can use the BackGroundWorker Class, it is designed for just this scenario, you also can implement progress indication so your user is not wondering what is happening by using the ProgressChanged Event:
Example: