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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:05:21+00:00 2026-06-04T06:05:21+00:00

Basically it’s this question but then for VB.net. I need to check the CheckBox

  • 0

Basically it’s this question but then for VB.net. I need to check the CheckBox state from another thread than the main thread. Solutions for the linked question contain C# code. On-line translators do not yield understandable results.

My code (stripped down to the essential parts):

Public Class UI
    'UI contains CheckBox1.
End Class

Public Class Worker
    Public Sub Input()
        Dim thrMyThread As New System.Threading.Thread(AddressOf Run)
        thrMyThread.Start()
    End Sub

    Public Sub Run()
        If UI.CheckBox1.Checked = True
            MsgBox("True")
            ShellandWait("application.exe")
        Else
            MsgBox("False")
            ShellandWait("application.exe")
        End If
    End Sub

End Class

ShellandWait is a custom function which starts a process and waits until it exits.
Because of the ShellandWait I need another thread to keep my UI responsive.

UPDATE
I did find a work around by defining a Public boolean variable at the beginning of the Worker Class, which represents the state of the UI.CheckBox. So:

Public Class Worker
    Public cB As Boolean = UI.CheckBox.Checked
    ... 'Rest of Code
    Public Sub Run()
        If cB = True
            MsgBox("True")
            ShellandWait("application.exe")
        Else
            MsgBox("False")
            ShellandWait("application.exe")
        End If
    End Sub
End Class
  • 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-04T06:05:24+00:00Added an answer on June 4, 2026 at 6:05 am

    This should work. This code will enable you to access the GUI from worker-threads.

    Public Delegate Function GetCheckBoxChekedDelegate(cb As CheckBox) As Boolean
    
    Public Function GetCheckBoxChekedFunction(cb As CheckBox) As Boolean
        Return cb.Checked
    End Function
    
    Public Function GetChecked(cb As CheckBox) As Boolean
        If cb.InvokeRequired Then
    
            Dim del As GetCheckBoxChekedDelegate
            del = AddressOf GetCheckBoxChekedFunction
    
    
            Dim parArray() As Object = {cb}
    
            Return CBool(cb.Invoke(del, parArray))
            'Return CBool(cb.Invoke(del, New Object() {cb}))
            'Return CBool(cb.Invoke(del, {cb}))
    
        Else
            Return cb.Checked
    
        End If
    End Function
    

    You can use the GetChecked function to get the checked state of the checkbox, the function will works both on the main thread, and on a worker thread.

    When the GetChecked function is called from a worker thread the InvokeRequired will return true, so the cb.Checked value is read in the function GetCheckBoxChekedFunction which is called on the main thread by the cb.Invoke(del, {cb}) command.

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

Sidebar

Related Questions

Basically from a database I am getting data that is formatted like this nameofproject101
Basically I'm attempting to add rows to a table, I need to do this
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I want to achieve this workflow: Checkout from repository on windows system (or
Basically I need to be able to do this: var obj = {foo:bar}, arr
Basically, what the question title says. Thread t = new Thread(someRunnable); t.start(); t.interrupt(); t.join();
basically i have (state, state code) pairs, that are subsets of country [USA] ->
Basically what I need to do is write a function that takes in a
Basically I'd be looking to implement a method like this. IQueryAble GetQuery<T>(Entities db) or
Basically I have an iframe loaded that is accessed from the parent whenever it

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.