DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 02 Jul 2007 05:49:18 -0700,    posted on: microsoft.public.dotnet.framework.interop        back       

Thread Index
  1    unknown
          2    Christian Fröschlin
          3    Willy Denoyette [MVP]


.NET remoting and COM strange behavior   
Hi,

I have following strange problem. I run remote object using .NET
remoting.
This remoting object creates some COM object (STA) and executes some
methods.
The strange behavior is that if I print GetCurrentThreadId inside
remote object I see
that each call run in different thread id, but print from COM object
gives me same
thread id all the time. Under the stress it hase same exactly
behavior.
Can anyone explin me why it happens? Is there any article about this
in MSDN?

Thanks,
Maxim.
Date:Mon, 02 Jul 2007 05:49:18 -0700   Author:  

Re: .NET remoting and COM strange behavior   
zabutimaxim@gmail.com wrote:


> This remoting object creates some COM object (STA) and executes some
> methods.
> The strange behavior is that if I print GetCurrentThreadId inside
> remote object I see
> that each call run in different thread id, but print from COM object
> gives me same
> thread id all the time.


By definition of STA, all calls to the COM object are executed
in the thread which *created* the object. Create an MTA object
if this is not what you want.
Date:Mon, 02 Jul 2007 15:19:51 +0200   Author:  

Re: .NET remoting and COM strange behavior   
wrote in message 
news:1183380558.740233.113400@q75g2000hsh.googlegroups.com...

> Hi,
>
> I have following strange problem. I run remote object using .NET
> remoting.
> This remoting object creates some COM object (STA) and executes some
> methods.
> The strange behavior is that if I print GetCurrentThreadId inside
> remote object I see
> that each call run in different thread id, but print from COM object
> gives me same
> thread id all the time. Under the stress it hase same exactly
> behavior.
> Can anyone explin me why it happens? Is there any article about this
> in MSDN?
>
> Thanks,
> Maxim.
>



"Apartment" threaded objects cannot run on an MTA thread, they *must* run on 
a STA thread, this is automatically taken care of by COM. That means that 
your objects are getting created on a "COM" thread that is initialized to 
enter an STA and your calls will get COM marshaled by a proxy/stub pair from 
the MTA thread to the COM STA thread.
In order to prevent the marshaling overhead (and other marshaling related 
issues), you should try to re-implement your COM objects as free threaded.

Willy.
Date:Mon, 2 Jul 2007 18:13:07 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us