Re: Questions about apartment threading models



"Kürþat" <kursattheking@xxxxxxxxx> wrote in message
news:%23f$gbVEjJHA.4028@xxxxxxxxxxxxxxxxxxxx
I couldn't completely grasp meaning and usage of MTA and STA threading
models.

http://support.microsoft.com/kb/150777

1- Are the apartments only related to COM?

Yes.

2- Is there any apartment in a Win32 processes which never make any
COM call?

Apartments don't make COM calls - programs do. Of course there exist
Win32 programs that never make any COM calls - not even CoInitialize.

3- Is an apartment programatically creatable?

When a thread joins an apartment (by calling CoInitialize[Ex] or
OleInitialize) that didn't exist before, an appropriate apartment is
automatically created.

4- What is the role the apartments play in Win32 development, why do
they even exist?

To allow multi-threaded clients to safely access thread-unsafe COM
objects, and vice versa.

5- When and how does a pointer belong to an apartment?

Pointers don't belong to apartments - COM objects do. I guess one may
say that a pointer to an interface implemented by an object living in
some apartment belongs to that apartment.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Questions about apartment threading models
    ... Of course there exist Win32 ... an appropriate apartment is ... Pointers don't belong to apartments - COM objects do. ... apartment belongs to that apartment. ...
    (microsoft.public.win32.programmer.ole)
  • Re: atldbcli.h line 6200 (VC 7.1):
    ... In the case of the 'disappearing apartment', ... process shutdown where you'll have stray pointers. ... When that global's FinalRelease is called, ...
    (microsoft.public.data.oledb)
  • Re: atldbcli.h line 6200 (VC 7.1):
    ... In the case of the 'disappearing apartment', ... process shutdown where you'll have stray pointers. ... When that global's FinalRelease is called, ...
    (microsoft.public.vc.atl)
  • Re: STA vs. MTA when calling out-of-process objects
    ... switched to retrieving the interface pointers always from the GIT. ... apartment than the one that created it, ...
    (microsoft.public.vc.atl)