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
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
0
votes
2 answers

Error When Switching Tenant Using Apartment Gem

i am getting error when execute Apartment::Tenant.switch!("tenant_name") even when the tenant were exists. When i run Apartment::tenant_names,it return an array contain ["murah5","rahmatullah","test"] then i run Apartment::Tenant.switch!("murah5")…
0
votes
1 answer

How can I set the COM apartment state for code loaded with `AppDomain.ExecuteAssembly`?

When I create a Thread, I have the option of setting its COM apartment state explicitly before I start it. For example: // using System.Threading; var thread = new Thread(…); thread.SetApartmentState(ApartmentState.STA); thread.Start(); But when I…
stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
0
votes
6 answers

WebBrowser.Navigated Only Fires when I MessageBox.Show();

I have a WebBrowser control which is being instantiated dynamically from a background STA thread because the parent thread is a BackgroundWorker and has lots of other things to do. The problem is that the Navigated event never fires, unless I pop a…
tsilb
  • 7,977
  • 13
  • 71
  • 98
0
votes
0 answers

Single-threaded apartment model - how to handle a COM object creating a worker thread?

I have a COM object implemented in a STA EXE (calls CoInitialize(NULL)), let's call it CMyObject which implements IControl. Pseudo code is like this: IControl { Start(); Stop(); }; CMyClass : IControl { public: Start() { //create an…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
0
votes
1 answer

TimerCallback Delegate to drive an STA model .NET library component

I'm trying to use the TimerCallback Delegate mechanism to drive instances of objects from a 3rd party .NET library component on separate threads executing on a timed basis. When I try to create an instance of an object from the library I an…
acheo
  • 3,106
  • 2
  • 32
  • 57
0
votes
0 answers

How to change apartment model in already existing Visual Studio C++ project?

I have a Visual C++ 2013 project that was created using COM wizard. When creating this component Apartment model was chosen. Is there any way to change this model to different apartment without recreating the project from scratch?
JonasJnz
  • 33
  • 2
  • 6
0
votes
0 answers

WMI call works in GUI thread (STA Thread), why does it fail in background threads (MTA Threads)?

Okay, I have a method which simply backs up the Windows event logs as *.evt files. In .net2.0 on Windows XP x86 and x64, this worked great, no issues. We recently upgraded to .net4.0 (4.0.3 specifically) and now this code is failing in a very…
Curtis
  • 1,189
  • 2
  • 11
  • 22
0
votes
1 answer

Com Threading/Apartment behavior inconsistent with a marshalled factory

I'm trying to use CoRegisterClassObject to customize the way I load dll's that have com objects in them. I'm trying something out that will solve a problem I was having when the thread's apartment type didn't match the com object's. The basic idea…
bdwain
  • 1,665
  • 16
  • 35
0
votes
0 answers

coregisterclassobject doesn't work with a class factory marshalled from another thread

I'm trying to use CoRegisterClassObject to customize the way I load dll's that have com objects in them. I'm trying something out that will solve a problem I was having when the thread's apartment type didn't match the com object's. I'm having a…
bdwain
  • 1,665
  • 16
  • 35
0
votes
1 answer

CoRegisterClassObject breaks thread safety

I'm testing out a custom class factory that will be registered using coregisterclassobject, and I'm noticing that it causes threading problems. I created a test com object and created an instance of it, and everything behaved as expected. It's an…
bdwain
  • 1,665
  • 16
  • 35
0
votes
1 answer

What does the term "input-synchronized calls" mean?

I found this in an article on Multithreaded Apartments, but can’t find a definition for “input-synchronized calls”. (Article is at http://msdn.microsoft.com/en-us/library/ms693421(VS.85).aspx) As used in the article - Multithreaded apartments…
Binary Worrier
  • 50,774
  • 20
  • 136
  • 184
-1
votes
1 answer

Unable to set thread concurrency model to multithreaded apartment

I've created a new DUnit Test Project and I am trying to setup multithreaded apartment at its start. The problem is that on one computer apartment type is changed. program COMApartment; {$IFDEF CONSOLE_TESTRUNNER} {$APPTYPE CONSOLE} {$ENDIF} uses …
Wodzu
  • 6,932
  • 10
  • 65
  • 105
-1
votes
1 answer

Unable to create an object of com components written in unmanaged code from .Net wcf service

I am writing a Wcf Service library and want to load an unmanaged com dll. The com dll threaded model is not set so its a Single-threaded legacy component that runs only in the main STA threading model In wcf service, I have set the apartment as STA…
Amjad
  • 1
  • 1
1 2
3