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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:08:00+00:00 2026-05-14T22:08:00+00:00

After exploding with excitement over learning about how to make thread-safe calls to Windows

  • 0

After exploding with excitement over learning about how to make thread-safe calls to Windows Form Controls, it got me thinking…

Why aren’t all calls to Windows Form Controls thread-safe? Can anyone explain why? I would think it would reduce a lot of confusion for users of those controls.

  • 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-14T22:08:01+00:00Added an answer on May 14, 2026 at 10:08 pm

    The issue here is not one of thread safety. The methods are all “thread safe” in that they do not corrupt the state of the application when called simultaneously on multiple threads – it is just that thread safety includes throwing a wrong thread exception (can’t remember what it is called).

    What they have is thread afinity – they can only be called on one thread – sometimes referred to as the UI thread, although this is misleading because it implies there is only one. This is mainly because the OS calls they depend on have the same thread affinity rules.

    Trust me – this is a good thing. When you think about the primary role of the “UI Thread” it all starts to become clear. The UI threads job is to take input from the users hands, through a keyboard or mouse, act upon it, and produce output in the form of pixels in response. There is only one user, and that user only has one set of eyes. The user expects to see everything they do happen on the screen, and most importantly they expect to see it happen in the order they did it. Multithreaded UI would make this very difficult to achieve – almost impossible.

    The problem is that when you mix your background “worker” threads with the UI thread, you need to do a certain amount of marshalling to talk to the UI because you have to be on the UI thread to do it. Again, as I said, this is a good thing. Someone has to do this marshalling, else the user would see things happening in the wrong order and that is bad. The system could admittedly do it for you, and in some WIN32 calls it does – but this has problems. First of all, the system can’t know what granularity you need the marshalling to occur at so you might end up being inefficient. Your operations might be better marshalled at a higher level than the system can understand. Secondly, the marshalling is expensive, and it punishes the developers who are doing the right thing and moving everything over to the UI thread correctly. So the system does the minimum thing it can, check if it is on the right thread and if not, throw an exception.

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

Sidebar

Related Questions

I'm exploring package building on Windows 7 but have been running into trouble after
After deploying WCF server (svc) on my Server, I have got this message when
After discovering about Javascript namespaces, I tried to implement them but I run into
After a long search I'm still confused about it although I found some related
After exploring the very excellent answer from Heike to my previous question about anamorphic
I have two controls on my form: a listbox with a list of workers
I posted a question re LDAP account management, but after exploring this, it's not
Weird problem: After rotating my app to portrait, picking the toolbar item and exposing
After a system upgrade i am no longer able to start my tomcat5 server.
After some time researching and trying different things I still cannot get my @ExceptionHandler

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.