--
Egbert Nierop
Session management for webfarms:
http://www.nieropwebconsult.nl/asp_session_manager.htm
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:#xwDd0FjBHA.2688@tkmsftngp04...
"atl" <only...@pub.dgnet.gd.cn> wrote in message news:<#xwDd0FjBHA.2688@tkmsftngp04>...
http://msdn.microsoft.com/library/en-us/cossdk/htm/pgservices_synchronizatio
n_8703.asp?frame=true
tutorial on apartment programming
http://msdn.microsoft.com/library/en-us/com/aptclien.asp?frame=true
--
Egbert Nierop
Session management for webfarms:
http://www.nieropwebconsult.nl/asp_session_manager.htm
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:#Xvc$PTjBHA.2168@tkmsftngp05...
V.v. - every object live in apartment if it Initialize as apartment model.
As I can understand you the question is if
thread which produced in some method live in this apartment , the answer is
no
Arkady
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:#xwDd0FjBHA.2688@tkmsftngp04...
Those are about the only operations that can be thought of as being
performed on an apartment: thread joining or leaving one, and thread
belonging to one apartment marshaling an interface pointer so it can be
unmarshaled and used in a thread belonging to another apartment.
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:e87B7aekBHA.4792@tkmsftngp04...
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:OHiOFnmkBHA.1684@tkmsftngp03...
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:OoS3kK6kBHA.1684@tkmsftngp03...
problem A: what does apartment mean, a piece of memory as part of process
memory space?
problem B: how could u figure out & enum those apmartments even orally?
problem C: i just want to implement a com class not by atl. can i do that?
A thread can belong to none or one apartment. STA (single-threaded
apartment) can have exactly one thread. MTA (multi-threaded apartment)
can have one or more threads. There may be many STAs in a process, but
no more than one MTA.
Thus, a COM object belonging to an STA is never called concurrently,
since is can only be called by the thread belonging to the same STA, and
there cannot be more than one of those. So STA object does not have to
worry about protecting data against concurrent access, and can safely
use thread-affine APIs, such as GUI. A COM object belonging to MTA can
be called concurrently, and must protect its data accordingly.
B: When a thread calls CoInitialize or
CoInitializeEx(COINIT_APARTMENTTHREADED), it is considered to belong to
an STA. Since STA can have only one thread, every STA in the process is
distinct, so there are as many STAs as there are running threads that
have called one of those init functions and have not yet called
CoUninitialize. When such a thread calls CoUninitialize, it no longer
belongs to its STA. Its STA is no more.
When a thread calls CoInitializeEx(COINIT_MULTITHREADED), it is
considered to belong to an MTA. All threads that do this enter the same
MTA, so there can be only one MTA per process. A thread calls
CoUnitialize to leave MTA. I'm not sure when MTA is destroyed: either
when the last thread leaves it, or when the thread that was first to
enter MTA (and thus essentially created it) leaves it. Maybe Alexander
Nickolov will help me here.
So if you know the threads your program creates, you can figure out the
apartments those threads enter.
C: Sure you can, though it's a lot of pain. "Inside OLE" by Kraig
Brockshmidt, available online on MSDN under Books, walks through the
procedure.
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:ONhCl9$kBHA.2472@tkmsftngp04...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@geocities.com
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Igor Tandetnik" <itand...@whenu.com> wrote in message
news:e1hXY3GlBHA.2104@tkmsftngp07...
Unfortunately, COM uses CreateThread and not _beginthread(ex) to create
new threads, which may cause leaks as per KB Article Q104641 "INFO:
Using C Run-Time Functions and CreateThread()", especially for MTA
objects where threads come and go as they please. I have once seen a
complete list of RTL functions that should be avoided by MTA components,
but unfortunately I seem to have misplaced it. Note that the article
does not apply if you use RTL DLL - that one initializes its per-thread
data in DllMain(DLL_THREAD_ATTACH).
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:e8rbjWSlBHA.1592@tkmsftngp02...
or should i do that:
in the above interface methods, find a entry point to createthread,then
connect,
getsth,close, and use all of the syn features to synchornize all of this
threads.
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:ulFedPTlBHA.1684@tkmsftngp03...
i should say my question is (conceptionally):
how to divide the labor of threading-related & com-related working
in a performance-critical sulotion.
thanks.
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
"atl" <only...@pub.dgnet.gd.cn> wrote in message
news:#SEYovZlBHA.956@tkmsftngp05...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@geocities.com
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"atl" <only...@pub.dgnet.gd.cn> wrote in message news:#SEYovZlBHA.956@tkmsftngp05...