Questions tagged [sta]

Single-Threaded Apartment of the Component Object Model (COM), as opposed to MTA

STA refers to the Single-Threaded Apartment of Microsoft's Component Object Model (COM). Its opposite is the Multiple Threaded Apartment (MTA), but there is also a Neutral Apartment.

Related tags:

References:

230 questions
0
votes
1 answer

C# windows service and STA thread clipboard

After doing some searching, I've come to understand that when creating a windows service application, you can implement STA threads to access the clipboard as follows: thread th = new…
chris
  • 1
0
votes
0 answers

Memory leak in STA thread c#

I am creating an STA thread as I am basically using a UI component within a library that has functionality I want without actually having any UI (exporting tables to Excel). System.Threading.Thread thread = new System.Threading.Thread(() => …
Simon Nicholls
  • 635
  • 1
  • 9
  • 31
0
votes
1 answer

Using non-STA threads in VSTO projects to achieve parallelism?

It's clear that using a VSTO application, the main Office application is running an STA thread, and spawning other STA threads pose no problem (actually they do provide some challenges but we can handle them). The reason is that STA threads ensure…
Zeruno
  • 1,391
  • 2
  • 20
  • 39
0
votes
0 answers

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 messages to this apartament. My question is how to…
Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69
0
votes
0 answers

Trying to open a new window from a WPF window, I get STAThread exception

I have a wpf project, and I am trying to do a popup style window which is a separate wpf window I wrote. I am trying to do a simple Showdialog as I have done before on several other projects. I simply do the following from the MainWindow.xaml.cs …
Tamaska Janos
  • 61
  • 1
  • 6
0
votes
0 answers

How can I get the chosen file from a FileOpenPicker window in C++ winRT?

I have been able to come up with the following C++/winRT code which "almost works". I created a class with a method that returns IAsyncOperation so that I could use the co_await keyword; the method looks like this: IAsyncOperation
Juan Dent
  • 439
  • 2
  • 6
  • 14
0
votes
0 answers

Updating a UI component using Invoke Async Deadlock

I am using devexpress and their PivotGrid control to build a pivot grid. I don't care about displaying it I have no actual UI displayed, I want the PivotGrid so I can export it. Therefore I am creating and updating the pivot grid object on a…
Simon Nicholls
  • 635
  • 1
  • 9
  • 31
0
votes
3 answers

Hourglass cursor in multithread asnc application

I am trying to implement cursor changing when my application making big issue. I was trying this public class CursorWait : IDisposable { public CursorWait(bool appStarting = false, bool applicationCursor = false) { // Wait …
mikroice90
  • 137
  • 1
  • 9
0
votes
1 answer

Can SendNotifyMessage be used to get onto the COM STA thread?

I am working on an C++ MFC/COM application (including VBA and .NET code) that needs to execute code on the COM STA thread from another thread. One way, that works, is to use the PostMessage function to post a message to a hidden HWND_MESSAGE…
Marcus
  • 5,987
  • 3
  • 27
  • 40
0
votes
1 answer

How to change powershell "pwsh" to STA ApartmentState

I'm trying to port some scripts from poweshell 5.0 to the new pwsh powershell 6 and i've noticed that there is no -sta parameter anymore. How can I set the ApartmentState of pwsh? I can;t find anything about it and it looks like it's defined in…
Marco
  • 984
  • 10
  • 18
0
votes
1 answer

How can I call a function in C++ when I get the WinRT/UWP error 'Activating a single-threaded class from MTA is not supported?'

When attempting to call a single-threaded apartment (STA) function from the "wrong" thread (e.g., Clipboard::SetContent(...)), I see the following message: Activating a single-threaded class from MTA is not supported. It's not obvious which…
Andy Krouwel
  • 1,309
  • 11
  • 21
0
votes
0 answers

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 following The finalizer thread is probably tring to…
user2101801
  • 719
  • 2
  • 8
  • 20
0
votes
1 answer

Nothing happening when you click second time

I having terrible when i execute the same method second time.i am not getting WPF screen, I don't know why? refer my code TestWindow Button click method(it is windows application project type) and i have removed STA thread in my Main() TestClass…
Rajamohan Rajendran
  • 369
  • 1
  • 3
  • 13
0
votes
0 answers

Form Does Not Appear to be STAThread

I am profiling a colleague's C# application. The VS2015 analysis tool shows that 33% of exclusive samples occur in System.Windows.Forms.Application.Run. Nearly all of the computation occurs inside a click event, and the form is unresponsive as you…
Todd
  • 475
  • 4
  • 15
0
votes
1 answer

Is there a generic 'FuncSTA' for invoking delegates by a STA thread?

I have an ASP.NET application and need to use some COM components inside it. I need a wrapper class over Func or Action which creates a new STA thread and run the delegate with that thread or something like this. Do you know such a class or library…
Xaqron
  • 29,931
  • 42
  • 140
  • 205