In C# there is a method SetApartmentState in the class Thread.
How do I do the same thing in C++?
views:
441answers:
2c++ doesn't have built in thread support. What you are looking for depends on how you are implementing threads in your application. Win32? pthreads? boost::threads? Whichever API you are using will determine the answer to your question.
EDIT: looks like this may have an example for you: http://msdn.microsoft.com/en-us/library/system.threading.apartmentstate.aspx
It looks like it applies to managed c++.
For unmanaged processes, you control the apartment model used for a thread by passing appropriate parameters to CoInitializeEx(). Larry Osterman wrote up a great little guide to these:
...
When a thread callsCoInitializeEx(orCoInitialize), the thread tells COM which of the two apartment types it’s prepared to host. To indicate that the thread should live in the MTA, you pass theCOINIT_MULTITHREADEDflag toCoInitializeEx. To indicate that the thread should host an STA, either callCoInitializeor pass theCOINIT_APARTMENTTHREADEDflag toCoInitializeEx.
...
-- http://blogs.msdn.com/larryosterman/archive/2004/04/28/122240.aspx