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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:16:00+00:00 2026-05-16T14:16:00+00:00

I see there are a lot of questions regarding threads modifying items in a

  • 0

I see there are a lot of questions regarding threads modifying items in a form;
however, I just wanna read the state of a checkbox (for example) from a thread. So…

Is there any additional overhead to access the “Checked” state of a checkbox in a form (from a thread) -vs- creation of an bool that will reflect the state of that checkbox, and have the thread access the boolean instead?

  • 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-16T14:16:01+00:00Added an answer on May 16, 2026 at 2:16 pm

    The answer is most definitely yes. The reason is because accessing UI control state correctly involves a lot of work. You basically have to marshal a method call onto the UI thread to access a control properly. That marshaling operation requires sending a message to the UI thread via the message pump that contains a delegate reference. The UI thread will eventually pick it up and execute it. Since I have never timed this operation I cannnot say for sure how expensive it is, but I suspect it is a nontrivial amount of time. It has to be done this way because UI controls have thread affinity. That means they can only be accessed on the thread that created them. To marshal a delegate use the Control.Invoke or Control.BeginInvoke methods.

    Fredrik already mentioned one really good workaround for avoiding the marshaling operation. Here is what it might look like in code.

    public partial class YourForm : Form
    {
        // Make sure to mark this variable as volatile.
        private volatile bool m_Checked;
    
        private void YourForm_Load(object sender, EventArgs e)
        {
            m_Checked = YourCheckbox.Checked;
            var thread = new Thread(
                () =>
                {
                    while (true)
                    {
                      // This read will come from main memory since the
                      // variable is marked as volatile.
                      bool value = m_Checked;
                    }
                });
            thread.Start();
        }
    
        private void YourCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            // This write will be committed to main memory since the
            // variable is marked as volatile.
            m_Checked = YourCheckbox.Checked;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can see there are a lot of questions for getting the number of
There are a lot of questions here about Greasemonkey, but I didn't see anything
I see that there are A LOT of related questions on this one, and
I see there are lot's of examples in Ext JS where instead of actually
I am new to rails. What I see that there are a lot of
I see there are several posts regarding Cannot set Property and I'm still struggling
I know there are a lot of questions out there for facebook integration, and
I know, there are already a lot of similar questions here but I did
I am working with a Drupal theme, and I see a lot of variables
I see there are techniques available to have deep models in Backbone, but how

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.