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 6672291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:29:27+00:00 2026-05-26T03:29:27+00:00

For some reason a background thread in my app can’t change any labels, textbox

  • 0

For some reason a background thread in my app can’t change any labels, textbox values, etc on my main form. There is no compile errors, when the thread executes nothing happens.

Here is some example code:

Imports System.Threading

Public Class Class1
    Dim tmpThread As System.Threading.Thread

    Private Sub bgFindThread()
        Form1.lblStatus.Text = "test"
    End Sub

    Public Sub ThreadAction(ByVal Action As String)
        If Action = "Start" Then
            tmpThread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf bgFindThread))
            tmpThread.Start()
        ElseIf Action = "Abort" Then
            If tmpThread.IsAlive = True Then tmpThread.Abort()
        End If
    End Sub

End Class

Can someone let me know what I’m doing wrong?

  • 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-26T03:29:28+00:00Added an answer on May 26, 2026 at 3:29 am

    AFAIK code above will throw an exception IllegalCrossThreadException, it is because the background thread is not the same as UI thread and background try to set value on other thread. So windows form check every thread that work properly.
    You can set Control.CheckForIllegalCrossThreadCalls to false to make it works.

    Code below is when setting property is not run

    Add into your code
    ------------------------------
    Delegate Sub MyDelegate()
    Private Sub RunMyControl()
      lblStatus.Text = "test"
    End Sub
    
    Change your code
    ------------------------------
    Private Sub bgFindThread
      lblStatus.BeginInvoke (New MyDelegate(AddressOf RunMyControl))
    End Sub
    

    The method asyncronsly run code from background thread to UI thread.

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

Sidebar

Related Questions

How can I get an indication to main UI thread in an iPhone app
For some reason my CSS Gradient isn't working in Firefox (v10.0.1). The main background
For some reason the background does not appear. This is the CSS div.sidebar_beige {
Background: For some reason, whenever a user tries to open an xslx (excel 2007)
For some reason, whenever I scroll through my list of items, the background inside
For some reason beyond me I can't access the mysql server on a machine.
Situation Well, as you can see below, I have a main App, creating a
I use performSelectorInBackground to do calculations on a background thread to keep the main
For some reason, when you apply a background image to a tr in Safari
here is my html for some reason the header tag isnt accepting the background

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.