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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:07:00+00:00 2026-05-14T07:07:00+00:00

I recently updated an application from VS2003 to VS2008 and I knew I would

  • 0

I recently updated an application from VS2003 to VS2008 and I knew I would be dealing with a host of “Cross-thread operation not valid: Control ‘myControl’ accessed from a thread other than the thread it was created on” I am handling this in what I beleive is the correct way (see code sample below). I am running into numerous controls that are going to need a similar fix. Not wanting to have similar code for every label, textbox etc.. that are being accessed by a non UI thread. What are the ramifications of just setting the CheckForIllegalCrossThreadCalls = false for the entire app?

I found a CodeProject article with various workarounds and a warning at the bottom to NOT set the property. I am looking for other opinions/experiences on this issue.

private void ShowStatus(string szStatus)
{
    try
    {
        if (this.statusBar1.InvokeRequired) { BeginInvoke(new MethodInvoker(delegate() { ShowStatus(szStatus); })); }
        else { statusBar1.Panels[0].Text = szStatus; }
    }
  catch (Exception ex)
  {
    LogStatus.WriteErrorLog(ex, "Error", "frmMNI.ShowStatus()");
  }
}

I found another article with some possible solutions SO Question 2367718

  • 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-14T07:07:01+00:00Added an answer on May 14, 2026 at 7:07 am

    When you’re not debugging, you’ll still have problems.

    From the documentation of Control.CheckForIllegalCrossThreadCalls:

    Note that illegal cross-thread calls will always raise an exception when an application is started outside the debugger.

    You’ll need to correct the problems.

    That being said, you mentioned:

    Not wanting to have similar code for every label, textbox etc.. that are being accessed by a non UI thread.

    I would reconsider this stance. You should try to move the logic running on a separate thread into separate methods or classes, which will in turn make marshaling the calls back into the UI much simpler. Over time, this will make your code much more reliable and maintainable.

    Note that you can use Control.Invoke to marshal a whole set of calls to the UI in one call, too, instead of doing each single set operation individually. There really shouldn’t be that many of them, when you finish.

    Edit:

    For example, it sounds like you’re loading the data. Say you have (on your background thread), your data loading method:

    var myData = LoadData();
    this.Invoke( new Action( () =>
        {
            // Just set all of your data in one shot here...
            this.textBox1.Text = myData.FirstName;
            this.textBox2.Text = myData.LastName;
            this.textBox3.Text = myData.NumberOfSales.ToString();
        }));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently updated the SwingX library in an application from version 1.0 to 1.6.2
I've recently updated an application to the 3.5 framework (from 2.0). The app links
I recently updated jasperreport version from 3.5.2 to 4.0.2 and noticed a few changes
I've recently updated from hibernate 3.3.1.GA to hibernate 3.5.0 and I'm having a lot
We recently updated our WPF application to perform its data synchronisation (using sync framework)
I've recently updated my Internet Explorer version from 8 to 9. Now, I'm getting
I've recently upgraded from Grails 1.1 to Grails 1.1.1. I've updated my projects accordingly
Our application uses H2Sharp to access a H2 database from C# (Framework v4). Recently
Hello, we have recently updated an application to Rails 3.0.4 (3.0.5 on online devel
I recently updated my VS2010 website project from .NET 3.5 to 4.0. Everything was

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.