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
1
vote
0 answers

Events from COM: works fine in WinForms/WPF but doesn't work in ASP.Net

Please tell me why does the following work fine in WinForms/WPF and not in ASP.Net. We have a class library targeted for .Net 3.5. It has an interop referenced (generated from TLB). public class MyClass { public delegate void…
user1307346
  • 715
  • 3
  • 9
  • 14
1
vote
3 answers

Variance matrix from polar to cartesian coordinates

I am dealing with a time series in polar coordinates and I am applying the Kalman filter for predictions. The time series is related with the satellite orbite. However my prediction and estimation for the variance are expressed in polar coordinates…
JPV
  • 1,079
  • 1
  • 18
  • 44
1
vote
2 answers

STA Thread is not loading the Main Window in WPF

I am loading MainWindow in App_Startup (). I wanted to show the progress bar while loading the window. But it is not working : void App_Startup(object sender, StartupEventArgs e) { Thread bootStrapThread = new Thread(new…
Kunal Deo
  • 2,248
  • 2
  • 18
  • 27
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
  • 383
  • 1
  • 6
  • 16
1
vote
1 answer

How can I use an object after use it in a STA thread?

I'm doing a Microsft PowerPoint add-in solution whit VSTO that reads info from a hardware, hardware developers gave me their SDK to control this hardware but I'm having problems trying to control it. I have this library ARS There is a class…
oscargilfc
  • 339
  • 1
  • 12
1
vote
3 answers

STA, MTA and OLE nightmare

I have to include a .NET application into another .NET application as a plugin. The plugin interface requires me to inherit from a template form. The form is then attached in a MDI when the plugin is loaded. Everything is working so far, but…
xsl
  • 17,116
  • 18
  • 71
  • 112
1
vote
3 answers

Why is this COM interop event not raised whilst running under an STA thread?

Can somebody please explain why the event "OnNewMail" is not raised when using an STA thread in the code below? The program attempts to use the Redemption library to intercept incoming outlook mails. class Program { [STAThread()] //…
Dan Ryan
  • 624
  • 7
  • 24
0
votes
1 answer

Get User info in WCF-service with [STAOperationBehavior] attribute

I have a silverlight-enabled WCF-service, of which one method absolutely requires the [STAOperationBehavior] attribute. I need to access user details (Forms Authentication) for the user, but Membership.GetUser() fails while the…
user495625
  • 301
  • 2
  • 11
0
votes
1 answer

Using main form as Parent to a new form created on different thread

I have a main form that runs a BackgroundWorker thread. While the worker is running I "freeze" the main form and wait for it to finish while showing its progress. In one on the scenarios the worker can display an OpenFileDialog for the user to…
Yoram
  • 179
  • 1
  • 2
  • 9
0
votes
1 answer

wpf threading, thread must be STA

I have a window(say main window) with a frame which has a page in it. A button on the page opens another window(say popup window). Now i am trying to invoke a method in the main window from a button on the popup window. The method has to be…
Sartaj Singh Gill
  • 1,074
  • 12
  • 21
0
votes
1 answer

C# WebBrowser Error Thread

I am having trouble getting a web browser in my form to work. When I run, I get this error ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. It takes me to…
user1008096
  • 535
  • 1
  • 5
  • 5
0
votes
1 answer

How to take a screenshot from a background thread using WinRT?

I'm having issues with WinRT ScreenCapture blocking/freezing my UI. My app is looping through selected windows and takes a screenshot of each every few seconds. Every time a screenshot is taken the UI animation is lagging and sometimes the UI just…
Ben
  • 793
  • 2
  • 13
  • 29
0
votes
0 answers

Calling another form with WebBrowser from mainform - giving ERROR?

I'm calling from3 from my form1 and its giving this error in InitializeComponent() Form3 frm = new Form3(); frm.Show(); Error "ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not…
1Mayur
  • 3,419
  • 5
  • 40
  • 64
0
votes
0 answers

EFCore add-migration error : Error: The calling thread must be STA, because many UI components require this

Error: An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: The calling thread must be STA, because many UI components require this. I just update my VisualStudio…
Eric Ouellet
  • 10,996
  • 11
  • 84
  • 119
0
votes
1 answer

How to create a STA thread for F# Asynchronous workflow

I am attempting to write a printed form in F# using WPF controls—-and do so in an asynchronous workflow. Being new to this, I can’t figure out how to place the wpf controls, consumed by the F# asynchronous block, on a STA thread, without blocking…
Alan Wayne
  • 5,122
  • 10
  • 52
  • 95