Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8770735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:36:56+00:00 2026-06-13T17:36:56+00:00

i have a function that contains the following WebUpdateThread = New System.Threading.Thread(AddressOf generatecids) WebUpdateThread.SetApartmentState(ApartmentState.STA)

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:36:58+00:00Added an answer on June 13, 2026 at 5:36 pm

    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:

    Imports System.Threading
    Imports System.ComponentModel
    
    
    Public Class Form1
        Dim WebUpdateWorker As BackgroundWorker
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            WebUpdateWorker = New BackgroundWorker
            AddHandler WebUpdateWorker.DoWork, AddressOf DoWork
            AddHandler WebUpdateWorker.RunWorkerCompleted, AddressOf WorkFinished
            WebUpdateWorker.RunWorkerAsync()
    
        End Sub
    
        Public Sub generatecids()
            System.Threading.Thread.Sleep(20000)
        End Sub
    
        Private Sub DoWork(sender As Object, e As DoWorkEventArgs)
            generatecids()
        End Sub
    
        Private Sub WorkFinished(sender As Object, e As RunWorkerCompletedEventArgs)
            MsgBox("something")
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a thread function on Process B that contains a switch to perform
I have a function that returns a table. The returned table contains (among other
I have a class header file called Grid.h that contains the following 2 private
Let's say I have a web page ( /index.html ) that contains the following
I have an assembly that contains a function that could be called from IIS
i have the following view that contains an @Html.DropDownList :- <fieldset> <legend>Answer here</legend> <div
I have a PartialViewModel in my MVC application that contains the following set up:
So I'm trying to write a function that does the following: I have about
I have the following function that executes an query and returns true on success
I have the following function that loops through a directory and checks for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.