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

  • Home
  • SEARCH
  • 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 521305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:14:11+00:00 2026-05-13T08:14:11+00:00

Sup Guys, I Have a Function on my frmMain Class wich will update my

  • 0

Sup Guys,

I Have a Function on my frmMain Class wich will update my control to something else after an invoke. When i type “?Label1.Text” on the Immediate Window, the text property IS updated, but when i go check the Form, nothing happened. The code is just like this

Public Sub UpdateUI()
    If (Me.InvokeRequired = True) Then
        Invoke(New MethodInvoker(AddressOf UpdateUI))
    End If
    Label1.Text = "ITS NOT WORKING =\"
End Sub

On my bgWorker Class:

Private threadUpd As New Threading.Thread(AddressOf Updater)
Private _active as Boolean
Public Sub New()
    _active = True
    threadLimpar.IsBackground = True
    threadLimpar.Start()
End Sub

Public Sub Updater()
    Do
        If (_active = False) Then
            Try
                Thread.Sleep(Timeout.Infinite)
            Catch ex As ThreadInterruptedException
            End Try
        Else
            if(condition...) then
              frmMain.UpdateUI
        End if
    Loop
End Sub
  • 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-05-13T08:14:12+00:00Added an answer on May 13, 2026 at 8:14 am

    It is a classic trap in VB.NET, everyone falls into it at least once when they start using threads:

    frmMain.UpdateUI
    

    Now we can’t see what exactly “frmMain” means. But the fact that you posted this question suggests that frmMain is the name of your main form class. Not the name of a field in your class that stores a reference to the main form.

    That doesn’t work. The variable that the VB.NET compiler generates to allow you to reference as class as though it is a variable has <ThreadStatic> semantics. In other words, every thread will create its own instance of a the form. You can sorta see it when you write it like this:

    frmMain.UpdateUI
    frmMain.Show
    

    But you’ll see a “ghost” of the window, it is otherwise dead as a doornail since the thread it was created on is not pumping a message loop.

    You’ll need a real reference to the form. That could be “Me” if Updater is a method of the form class. If it isn’t, Application.OpenForms could provide it. Best thing to do is the give the class that contains Updater a reference to the form through its constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 298k
  • Answers 298k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've already answered an incredibly similar question today, so look… May 13, 2026 at 7:30 pm
  • Editorial Team
    Editorial Team added an answer if your SmtpMail.Send(message) method returns no error, it means the… May 13, 2026 at 7:30 pm
  • Editorial Team
    Editorial Team added an answer At least in my version of Emacs, that is the… May 13, 2026 at 7:30 pm

Related Questions

I'm trying to create a function that searches up a WebControl's parent-child relationship (basically
Ok, I have been working with Solaris for a 10+ years, and have never
Namely, how does the following code: var sup = new Array(5); sup[0] = 'z3ero';
I have some .dat and .idx files and one .sup file in a directory
If I have a <sup> element in a multi-line paragraph, the line with the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.