Click here to Skip to main content
12,816,490 members (34,436 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: MFC GUI
I've heard that GUIs are generally not thread-safe, and this seems to be true across multiple GUI libraries (such as MFC and WinForms, for instance). I have seen crashing or odd behavior caused simply by updating some text on a GUI object from a separate thread. Why are even the simplest GUI operations generally not thread-safe? Is there something inherent about GUIs that make them not thread-safe? Or rather, why do so few GUI libraries claim to be thread-safe?
Posted 23-Dec-12 10:16am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

The answer is really simple: cost and legacy. Thread safety is really resource costly. At the beginnings of windows and even win32 there was no real need to be thread-safe. Neither could I say today that most application do use this feature. In most cases you can reduce the usage of such tools to a minimum just by doing some organisation of your code and logic - and following best practices.
So, I think it is most likely a good approach to let coders decide when to use these features, than spending wealth of resources on nothing.

The problem with MFC is, that it can hardly evolve. It would use the strength, if such resource-costly things would become default. Thus you will miss some really fancy features, that are already present in other frameworks and languages...

In .net, at least, with features like anonymous delegates and lambda expressions, I think it is really not hard to do it, when needed (see this good article[^]). It could be even more simple - perhaps it will be in the future, but that's a matter of syntax or language tools, not of making everything thread-safe by default.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Performance is the reason, I suppose.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100