This post is written because when I wrote the multithreads application, mostly in UI contained apps, it will ask for using STA in some methods. Then, I really curious what it is and find out why need to use STA, and how about MTA. In short, STA and MTA indicates where the thread resources will be located. If some objects need like COM objects, they are not thread safe which don't handle thread synchronization, commonly used in UI compoment. To call COM objects in other threads, they need to marshal message to the STA thread using message pumping system.
References:
- http://stackoverflow.com/questions/127188/could-you-explain-sta-and-mta
- http://bytes.com/topic/c-sharp/answers/260741-difference-between-sta-mta
- http://en.wikipedia.org/wiki/Component_Object_Model
- http://en.wikipedia.org/wiki/Object_Linking_and_Embedding
- http://en.wikipedia.org/wiki/Marshalling_(computer_science)
No comments:
Post a Comment