Hi all,

I'm trying to explain results regarding calling STA object from
different .Net threads.

Scenarios are :

a:
 1. Creating a STA Object from the main thread.
 2. Accessing it from the main thread (which is marked by the STA
attribute) 10000 times
 3. Accessing it from another thread (MTA thread) 10000 tines.

b.
 1. Creating a STA Object from a MTA thread which exists afterwards.
 2. Accessing it from the main thread (which is marked by the STA
attribute) 10000 times.
 3. Accessing it from another thread (MTA thread) 10000 tines.

note: the Com object is a very simple one - only returns the current thread
id.

The results are as follows:

a.
takes about 30 ms to loop 10000 times when accessing the object from the
main thread.
It takes about 23 seconds to access it from MTA thread.

b.
takes about 20 seconds to loop 10000 times when accessing the object from
the main thread.
it takes about 300 ms to access it from a MTA thread (not the creator
thread).

Questions are:
1. In both scenarios we have a MTA thread that calls STA object (step 3)
but the result are two orders of magnitude different. Why?
2. In scenario 2 Step two (Acessing from STA thread the STA object) took
much longer than step 3. Shouldn't it be the same? after all the in both
steps (2 and 3) Inter-Apartment marshaling is involved.

Can someone clarify this or point me to an explanation?

thnx.
Mordi Shahar and Yuri shchors

P.S.

please email me also (mordy_sh@@inter.net.il) (remove on of the @ symbols)

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to