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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:51:40+00:00 2026-06-10T02:51:40+00:00

Could someone give me some ideas on the proper Thread Safe way to get

  • 0

Could someone give me some ideas on the proper “Thread Safe” way to get Label Text from a Form? I am currently getting a CrossThreadingMessaging exception. I know I should be using a delegate, but I am having issues getting this to work correctly. Can someone give me an example? I have a label in my main form that I want to get the text from. I have to make the call from another class. Any guidance here would be much appreciated.

Rob

Here is my scenario:

I have to create an application that will grab the weight from a USB scale and deliver this wait back to a legacy system via a DDE call. The legacy system makes a DDE call to my executable to get the weight via a emulator program. I am trying to mimic the old VB 5 application in a C# application. Believe me there are many other ways I would like to do this, but I was told to do it this way by management. I have captured the weight in the label text, but now I have to get the weight from the label on the main form and return it when the DDE OnRequest method is executed. This is where I am getting the CrossThreading exception. The OnRequest is in a class outside of the main form class of course.

  • 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-10T02:51:42+00:00Added an answer on June 10, 2026 at 2:51 am

    Calling the property getter for a Label’s Text property can be done from a thread without invoking the IllegalOperationException you’d normally get. That’s an implementation detail, the value of the Text property is cached in an internal string. For example:

        private void button1_Click(object sender, EventArgs e) {
            var t = new Thread(() => Console.WriteLine(label1.Text));
            t.Start();
        }
    

    No exception. But setting the Text property will certainly invoke the hammer. This doesn’t otherwise make it a good idea to use this kind of code. Use threads to perform non-UI related work, give them what they need when you start them. And favor the BackgroundWorker class, it is very handy to give thread-safe progress updates and a thread-safe result.

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

Sidebar

Related Questions

Could someone please give me some advice/ideas about how to deal with the situations
I've got a small issue which I was hoping someone could give me some
Could some one give me pointers to tutorials that explains how to write a
Could someone give me a little direction on creating crossfades/dissolves between two UIImageViews in
Could someone give me an example of how to use the ContactPicker.PickSingleContactAsync() functionality correctly
could someone give me a brief explanation of what is happening differently in the
Could someone please give me a link on how to create a query in
I was hoping someone could give me a hand on how I write this
I've started using RhinoAutoMocker and I was wondering if someone could give me hand
I don't really understand Perl, so I was wondering if someone could give me

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.