Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
1k views

What is STA/MTA vs apartments/free threads vs UI threads/worker threads? Why the name changes?

I am reading Inside COM by Dale Rogerson, and it uses the terms apartment threads and free threads to describe the different types of COM threads. He also clarifies that these correspond directly to ...
citelao's user avatar
  • 5,936
4 votes
2 answers
551 views

Why is Task.Delay breaking the STA state of the thread?

Introduction This is a lengthy question! You will find some background on the problem at the beginning, then code samples, which have been simplified for representation and the Question after that. ...
ful-stackz's user avatar
0 votes
2 answers
471 views

How to access C++ COM Object in C# Background worker?

I am developing a common c# COM component (dll) which can be consumed by any COM client. As part of this I m exposing a outgoing interface called ICallback.The client which is using my dll will ...
srajeshnkl's user avatar
0 votes
0 answers
216 views

Sending messages to STA thread

I have read little bit about COM threading model: MTA and STA, for example this SO post: Difference between MTA and STA There we can read that to communicate with object within STA we need to pump ...
Michał Turczyn's user avatar
0 votes
0 answers
230 views

Method call on a STA COM component is hung

we have an .NET application which uses a COM dll, the ThreadingModel of this component is "Appartment" The Application always hangs calling a COM interface method. the DebugDiag analysis says the ...
user2101801's user avatar
3 votes
0 answers
211 views

Registration-Free COM not playing nice with single threaded objects. Activation context dropped during marshaling

I'm working on integrating a COM/CLI based library into a Java based application through JNI (yeah, it's a bit of a mess). For the most part it's working, but I've hit a bit of a snag when it comes ...
finalman's user avatar
  • 774
1 vote
1 answer
1k views

CoInitializeEx(COINIT_MULTITHREADED) and Goroutines using WMI

We have a monitoring agent written in Go that uses a number of goroutines to gather system metrics from WMI. We recently discovered the program was leaking memory when the go binary is run on Server ...
Greg Bray's user avatar
  • 15.7k
2 votes
1 answer
591 views

Calling STA COM object from WebApi

Is C#'s Runtime Callable Wrapper around a STA remote application type library safe (from the thread model and apartments perspective) to be called from a MTA thread context (.Net WebApi request)? ...
EProgrammerNotFound's user avatar
1 vote
2 answers
779 views

STA or MTA for indirectly used COM Objects

I think I understand the apartment concept and why STA or MTA is used, however a question came up for which I found no solution so far. If my application uses COM Objects under the hood, for example ...
DanielG's user avatar
  • 1,237
0 votes
0 answers
434 views

c# force call to out of process COM server from MTA thread to call back into same thread

I am writing a DLL that is called by a third party application. The DLL is called from an MTA thread and any calls back to the third party application must be done on the same thread. From my ...
Adriaan's user avatar
  • 172
0 votes
1 answer
59 views

ThreadingModel Free crashes the WCF service

I have a non-singleton WCF (standalone) service running some COM objects. In non-WCF environments, using Thread.Start, these COM objects happily run in parallel in different threads, utilising all ...
Vadim Berman's user avatar
  • 2,012
2 votes
1 answer
133 views

Implementation of MTA COM server

I can't find any source code on the prerequisites of an MTA compliant COM. I tried changing the ThreadingModel registry key of my object from Apartment to Both, and it results in a crash when a ...
Vadim Berman's user avatar
  • 2,012
1 vote
1 answer
608 views

Sample OPC client with STA and MTA

Where to find the information about COM threading model used for the OPC client, as part of OPC lab certification process I have to verify that OPC client can be implemented using different COM ...
user1504393's user avatar
1 vote
1 answer
2k views

ASP.NET Web Api with COM dll

I have ASP.NET Web Api project where I need to use VB6 Com dll. I have one controller, where I create object of class from com dll and use that object in my action. Everything seems to work when I ...
Bartosz Bialecki's user avatar
0 votes
1 answer
520 views

Out of process COM server in MTA issues

We have an out-of-process server running in MTA in a standalone application with UI. Server is initialized in following way. Scenario 1 initialization begin CoUninitialize; CoUninitialize; ...
danisius's user avatar
  • 597
0 votes
0 answers
1k views

When should I call CoUninitialize?

I implemented a function in a DLL encapsulates the asynchronous call to a Out-OF-Proc COM server. It looks like this: HRESULT hr = S_OK; bool bCoInitialized = false; IXXXXInterface* ...
fallwind's user avatar
0 votes
2 answers
406 views

Asp.Net Mvc and Win32 dll that is not designed for multithreading

I need to build a web application (MVC) that uses a third-party win32 dll as gateway for all business logic (contains logon-mechanism, functions and maintains some state). This dll is not designed ...
martinoss's user avatar
  • 5,458
0 votes
1 answer
256 views

WCF service and COM interop callback

I have a COM object that creates an instance of a WCF service and passes a handle to itself as a callback. The COM object is marked/initialized as MTA. The problem being every instance of the WCF ...
Sjblack's user avatar
  • 695
2 votes
1 answer
681 views

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 ...
user1371314's user avatar
2 votes
2 answers
3k views

Microsoft's Aparment Analogy (STA, MTA): Need help understanding it

I've read lots about the Microsoft's threaded apartment model, but I'm still having a little trouble visualizing it. Microsoft uses the analogy of living things living in an apartment. So, for STA, ...
Verax's user avatar
  • 2,519
12 votes
3 answers
14k views

COM outbound call results in "An outgoing call cannot be made since the application is dispatching an input-synchronous call."

I have a COM server (C++/STA (MFC based app)) and a COM client (C#/MTA). The COM server must live in an STA, since it's an MFC app (I have no choice in this matter). The client issues a call to the ...
Jörgen Sigvardsson's user avatar
2 votes
2 answers
2k views

Questions about COM multithreading and STA / MTA

Hi I am a beginner in COM. I want to test a COM dll in both STA and MTA modes. My first question is: is it possible a COM object supports both STA and MTA? Now I imagine the STA code snippet below: /...
Charlie's user avatar
  • 111
3 votes
3 answers
5k views

Aspcompat in ASPX Page

In my aspx pages, I call a COM component that uses STA. So I use aspcompat=true parameter, but I want to understand the logic. What does it exactly do? As far as I know, in STA, it is assumed to be ...
Feyyaz's user avatar
  • 3,206
2 votes
2 answers
1k views

QueueUserWorkItem with COM in C++

I have a performance issue where clients are creating hundreds of a particular kind of object "Foo" in my C++ application's DOM. Each Foo instance has its own asynchronous work queue with its own ...
David Gladfelter's user avatar
3 votes
1 answer
2k views

Winforms: One COM object needs an STAThread, the other needs an MTAThread. How can I use them?

I'm trying to build a Winforms application with two COM components. However, one of the components only works when using [MTAThread] and the other only works with [STAThread]. What would the ...
hb.'s user avatar
  • 1,755
2 votes
2 answers
1k views

Running REST/WCF as STA instead of MTA for COM

Is it possible to configure a REST (WCF) service to run as STA instead of MTA? This is approach is needed in order to run legacy COM objects. In order to configure ASMX web services to run as STA ...
user avatar
1 vote
3 answers
2k views

Is possible having two COM STA instances of the same component?

I had a problem discovered on another thread here, I need to access a COM component that is STA. I'll run it on a dual-core computer, a process using this component only reaches 50% of CPU. ...
Victor Rodrigues's user avatar