Questions tagged [apartments]

Concept in the threading model of the Component Object Model (COM), occurs in terms like STA and MTA

Apartments are groups of Component Object Model (COM) objects which can communicate directly. Communication between apartments is done via proxy, with extra care taken for calls to a Single-Threaded Apartment (STA).

Related tags:

References:

44 questions
2
votes
1 answer

COM+ long running method causing other methods to block/hang

I have a long running COM+ method that I need to be able to cancel from another thread. I am using C#/.NET to interact the COM+ objects. I configured both COM+ objects to have a "Free" threading model. This C# sample demonstrates how I intend to use…
Paul Knopf
  • 8,943
  • 21
  • 69
  • 131
2
votes
1 answer

Thread.Join in a shared hosting environment

I wonder if someone can help me - I've been programming VB.Net for a long time but have rarely had to do much threading in ASP.Net. I'm attempting to take "screenshots" of websites using an in-memory browser. These images are then logged in a DB and…
Basic
  • 25,223
  • 23
  • 108
  • 188
2
votes
1 answer

Out of process COM server with MTA

I have an out of proc COM (ATL) Server that has been created as free threaded (CComMultiThreadModel) I am slightly confused as to how that relates to the re-entrancy of calls into my object, for example I assumed that I would be allowed to call from…
user1371314
  • 694
  • 5
  • 18
1
vote
0 answers

Not able to handle com events in c#

How to handle com events in c#? I have created one class library in c# and exposed as com component with registry free com technique. [ComVisible(true)] [Guid("SOME GUID")] [InterfaceType(InterfaceType.InterfaceIsIDispatch)] public interface…
1
vote
1 answer

FreeThreadedDOMDocument, Neutral Apartments and Free-Threaded Marshaler

As MSDN states: If you are writing a single threaded application (or a multi-threaded application where only one thread accesses a DOM at one time), use the rental threaded model (Msxml2.DOMDocument.3.0 or Msxml2.DOMDocument.6.0). If you are…
1
vote
1 answer

To Marshal or Not to Marshal

I could not find the definite answer to the following question: if a COM class is thread safe, that is it is marked with Both or Free, do I really need to marshal its object interface to pass it to another thread in the same process? I do not ask…
andrebroz
  • 95
  • 7
1
vote
0 answers

Creating associated records after new user registration with Devise and Apartment

Background I have a multi-tenant Rails application which uses the Apartment gem to switch schema depending on their subdomain when they login. The User and Account entities are in the public schema. All of the other related entities are in the…
Rob Sobers
  • 19,173
  • 22
  • 78
  • 107
1
vote
0 answers

How can I explicitly set the apartment of an object in IClassFactory::CreateInstance instead of using the current thread's apartment

I am trying to register a custom class factory with CoRegisterClassObject, and the factory needs to be able to handle both STA and MTA objects. I'm noticing that IClassFactory::CreateInstance uses whatever threading model is specified for the…
bdwain
  • 1,425
  • 13
  • 31
1
vote
1 answer

How to make Quartz.net job to run in a single-threaded apartment?

I simply tried this: public class FooJob : IJob { public FooJob() { } public void Execute(JobExecutionContext context) { Thread.CurrentThread.SetApartmentState(ApartmentState.STA); } } But it produces…
Ashley Simpson
  • 373
  • 1
  • 5
  • 16
1
vote
2 answers

Do apartments "live" on the server side or on the client side in a out-process environment?

I' having an hard time trying to understand COM apartments in outprocess environment. Basically I can't understand why the client is required to call CoInitializeEx to register it's own thread in an apartment. I can understand object used by server…
Emiliano
  • 16,994
  • 10
  • 41
  • 59
0
votes
1 answer

0x80010100: System call failed" exception, ContextSwitchDeadlock

Long story short: in a C# application that works with COM inproc-server (dll), I encounter "0x80010100: System call failed" exception, and in debug mode also ContextSwitchDeadlock exception. Now more in details: 1) C# app initializes STA, creates a…
Igor R.
  • 13,922
  • 1
  • 42
  • 74
0
votes
0 answers

What is a COM threading appartment?

I registered a COM object with pywin32. win32com.server.register.UseCommandLine(TimeServer) I understand an apartment is some conceptual framework of keeping the threads and objects together? What is the point of apartments? A quote from Mark…
Borut Flis
  • 12,872
  • 26
  • 74
  • 102
0
votes
0 answers

Intermittent RPC_E_DISCONNECTED from in-process cross apartment calls

I am struggling with COM functions returning RPC_E_DISCONNECTED intermittently when performing cross apartment function calls from a client to a COM server. Most of the time, the problematic calls returns S_OK as expected, but once in a while, we…
0
votes
1 answer

In Single Thread Apartment model, is any call to a method is synchronised?

My doubt is that, in STA whether calls to different methods in the same interface is queued? or calls to the same method in same interface is queued?
TuneFanta
  • 69
  • 1
  • 9
0
votes
2 answers

STA applies to objects and functions?

My understanding of STA is that if my thread is running in an STA apartment then I do not have to worry about thread safety and calls to the functions of my thread are automagically queued. My question is that if I start a worker thread in STA and…
Grazi
  • 35
  • 4