Library tutorials & articles
Using User-Interface Threads
Introduction
I've never done a user-interface thread that has windows or controls. On the other hand, the complement of a worker thread is not necessarily a thread that has user-interface objects. The complement of a worker thread is a thread that has a message pump. This is a subtle but important distinction, but one that I have either needed or exploited, depending on circumstances.
Apartment Threading
I don't pretend to be an expert on "apartment threading". I fell into it because I needed to know a small number of things about it, specifically, how to get a SAPI-enabled application to run.
The key to "Apartment threading" is that an object which is initialized should be initialized in a particular thread and all operations on that object must be performed from that same thread. Trying to do operations on the same object from other threads is not guaranteed to work correctly. The point of this being that the object can be then written without worrying about incorporating thread-safe operations, because only one thread ever accesses it.
The Message Pump
What I needed to run SAPI in a separate thread was not a worker thread, but a thread with a message pump. The thread does not have to have GUI objects, and hence the name "User-Interface Thread" is a serious misnomer. The user interface may not even be relevant.
What SAPI requires is a message pump. So I had to start a "user-interface" thread. There were a couple problems, so this essay tries to capture my experience.
Related articles
Related discussion
-
job vacancy .Net Programmers - ( C# || C++ ) (5 full-time positions)
by tajulz (0 replies)
-
How to store C++ object pointers in Core foundation's ordered collections like CFMutableArrayRef, CFMutableDictionaryRef.
by elizas (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by Soft Industry (5 replies)
-
searhing numeric data in urdu text file.
by adilsajjad (0 replies)
-
Programming MS Visual C++, David J. Kruglinski - missing files needed
by andwan0 (0 replies)
Related podcasts
-
Concurrency Pt. 2
Podcast (MP3): Download Hosts: Alexander Michael Guests: Recording venue: In this second part of our concurrency series Michael and Alexander talk about basic patterns for concurrent programming, such as Active and Monitor Object, Scoped Locking and ...
This thread is for discussions of Using User-Interface Threads.