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
2
votes
1 answer

prevent event from spawning another thread

I bit ago I was reading about delegates and events (for a completely different reason) from this [website][1] In there I got the impression that if your event takes long enough a seperate thread is generated. Well that got me thinking about a bug…
Robert Snyder
  • 2,399
  • 4
  • 33
  • 65
2
votes
1 answer

Workflow 4.0 in a single threaded apartment?

I'm looking hard at WF 4.0 right now, but I'm having a hard time figuring out how to run workflows in STA threads. I've got a requirement for constructing XPS documents in a workflow, which means I need to create UI elements (FixedPage), which…
user1228
2
votes
1 answer

Why do I get an Invalid Operation Exception (non STA thread?) running this MSpec test on TeamCity?

As part of the migration of my app to .NET 4, I'm struggling to get some of the WPF unit tests working again with TeamCity. On all the tests that are somehow using a WPF control (a ListItem for example), I get an exception I didn't get…
Antoine Jaussoin
  • 5,002
  • 4
  • 28
  • 39
2
votes
2 answers

How to use STA mode in PowerShell 1.0?

I'm very awkward in PowerShell and I use it only at home for my own simple tasks under my Windows XP where no available upgrade to PS2. Next test show that my PowerShell 1.0 use MTA mode by…
Panayot Karabakalov
  • 3,109
  • 3
  • 19
  • 28
2
votes
1 answer

OutOfMemory exception in WPF video rendering application with COM interop

We have a rich client application developed using WPF/C#.Net 4.0 which interops with in-house COM DLLs. Regular events are raised via this COM interface containing video data. As part of the application we render video via Windows Media Foundation…
Greg_L
  • 21
  • 1
2
votes
1 answer

STATHREAD as async workflow in F#

Consider the following code fragment: let t1 = async { return process1() } let t2 = async { return process2() } let t3 = async { return windowsProcess() } let execute = [ t1; t2; t3 ] |> Async.Parallel |> Async.RunSynchronously |>…
Cay
2
votes
2 answers

Is STA Message Loop Required in This Case?

I've got some COM objects I'm creating and running on threads in a .NET application. The threads are marked as Single Threaded Apartments, and everything seems to be working. My understanding is that if these threads try to access COM objects from…
user12861
  • 2,358
  • 4
  • 23
  • 41
2
votes
2 answers

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 instead of MTA, there is a workaround available that…
BGBG
1
vote
0 answers

Parallel programming with STA Thread or TaskScheduler.FromCurrentSynchronizationContext()

I'm writing a code which produces the XPS file using WPF controls. Let's say 100 page document. As we know that since its using the WPF UI Elements it must be STA thread. Form the front end I have a web service which call the GenerateBook method in…
Abdullah
  • 39
  • 6
1
vote
0 answers

Inconsistency when calling in-proc registration-free com servcer from c#

I've encountered strange behavior when using registration-free com component. Here is what i have: Com component. I dont know what threading model it is designed for as i dont have source codes, but it works in STA for sure. Manifest for that…
koruyucu
  • 190
  • 1
  • 9
1
vote
2 answers

How can i write a dll function that uses the C# Keyboard Class

I want to use the following code to access the state of the keyboard at a certain time. using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Windows.Input; namespace some.any { public…
Johannes
  • 6,490
  • 10
  • 59
  • 108
1
vote
0 answers

Using STA for WebBrowser Control

I am trying to add a WebBrowser to an application to be able to display a webpage, but keep getting a problem with the threading type. Currently I am getting: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because…
Flipper
  • 2,589
  • 3
  • 24
  • 32
1
vote
0 answers

how can I check unused variables in python without using any SCA like pylint

I want to code a func that takes as an argment py folder . and warnes that there are unused variables. so I want to run over the variables in the folder and check them . I tried globals() , but in the folder may exist functions and variables so…
tarek
  • 11
  • 2
1
vote
2 answers

MsgWaitForMultipleObjectsEx deadlocks the main STA thread in MFC application

What is the best was to do STA thread synchronization? I have a dialog based MFC application with two STA threads: the main and the second. I created the COM object in the main UI thread. I call the COM interface from the second thread. In the main…
Charlie
  • 764
  • 2
  • 13
  • 24
1
vote
1 answer

How can I listen to this event on a different thread?

I've made a little test program to try and get a USB card reader working using an ActiveX control provided by the manufacturer. The form works fine as long as it doesn't use a separate thread. I create a new instance of Reader and listen to the Read…
Brandon
  • 68,708
  • 30
  • 194
  • 223