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

Can I run a QT or wxWidgets GUI from a STA dll?

I am currently evaluating options for porting an existing unmanaged C++ codebase to use a new GUI toolkit. QT and wxWidgets both seem like a good fit so far as they have a strong object model. The application is only targeted at Windows machines,…
Owen
  • 209
  • 1
  • 13
0
votes
1 answer

Using SmartThread with STA and event driven enviroment

Hi I have a use case where I am supposed to use C# Web Browser inside a form and get some data from it. However as we know the C# browser runs under STA hence I have created an instance of SmartThread with single thread architecture. On some events…
Sadanand
  • 107
  • 2
  • 11
0
votes
1 answer

Unloading AppDomain within not ThreadPool thread

I have System.Threading.Timer callback DoApplicationsToWorkSupervising. So it works pretty well on ThreadPool thread. What I actually need is executing application not only in separate domain but rather in STA thread to run WPF application. Sadly,…
alloha
  • 133
  • 1
  • 13
0
votes
0 answers

WPF: Main thread not frozen on binding

There are: two ListViews several libraries (imported by using MEF) Both lists need to get information from a library (one gets it on Loaded event, another - by binding with ItemTemplateSelector), but if there are several libraries with the same…
keymusicman
  • 1,281
  • 1
  • 10
  • 20
0
votes
0 answers

Changing the statuslabel.text on the GUI thread from inside a STA thread

I have tried to access a GUI element (a ToolStripStatusLabel) from inside a STA thread. Im having all sorts of issues trying to get invoke on it, thats becuase now i know there is no invoke for ToolStripStatusLabel, my latest error is: Error 1…
scott
  • 1,531
  • 2
  • 16
  • 29
0
votes
0 answers

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 application I need to call to an out of process COM…
Adriaan
  • 144
  • 13
0
votes
1 answer

Window closes immediately after being created (and shown) in a sepatarted thread

I was trying to instantiate and show a Window, when I got an exception saying {"The calling thread must be STA, because many UI components require this."} so I re-did it all in a separated STA thread as follows : var thread = new Thread(() => { …
AymenDaoudi
  • 7,811
  • 9
  • 52
  • 84
0
votes
0 answers

Why does WPF required to run in a Single Threaded Apartment?

Today I started with my WPF training and one of the points that came up was that it requires to run with STAThread attribute. I read Why does WPF require a STAThread attribute to be applied to the Main method? question and I understood the…
Piyush Parashar
  • 866
  • 8
  • 20
0
votes
1 answer

WPF mutex for multiple apps not working - STA issue

I've encountered an issue with Mutex class. I'm working in multi-instance WPF application and wanted to lock specific process from being entered by all other instance except the one that firstly called a method. So I've created a new mutex…
marczulajtis
  • 127
  • 2
  • 15
0
votes
0 answers

I have a error in make a new MainWindow in wpf

I have a error in my wpf project. When I want make a new from MainWindow in The following code: public App() { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); …
Amin
  • 387
  • 1
  • 6
  • 17
0
votes
1 answer

Getting STA error when try to open OpenFileDialog box in Excel addin project

I have created Excel addin project using Visual Studio to insert a data into database. The problem is I'm unable to open a File upload box in this. I am getting an error. My code: [ObsoleteAttribute()] [STAThread] private void…
Neo
  • 15,491
  • 59
  • 215
  • 405
0
votes
2 answers

How to create a separate STA thread for a WPF form that is inside of a dll and not a WPF application?

I have a dll that contains a WPF form. This dll will be called by another WPF application, which unfortunately I can't touch it. The problem is that there is no Main method in my WPF form to place [STAThread] static void Main() { //... } The…
Payam
  • 741
  • 3
  • 14
  • 37
0
votes
1 answer

STAThread error in Form created by another Thread

After my server class received all necessary information, it fires an event that is supposed to create a new Form. When clicking on a button on this form, I get an ThreadStateException. I know that I should alawys open a form within the main…
null
  • 1,369
  • 2
  • 18
  • 38
0
votes
1 answer

FileSystemWatcher .Net 3.5

Just switched from .Net 1.1 to 3.5 on Win service active for 10 years with over 2 million files processed. I have an asynchronous class that prints graphics to a PDFPrinter with a FileSystemWatcher event handler, now on its own STA thread,…
beanmf
  • 493
  • 5
  • 7
0
votes
1 answer

System.Threading.ThreadStateException in ASP.NET MVC 5 when Acquire Token from WAAD

I'm implementing the following scenario: ASP.NET MVC 5 application access OData WebAPI with Azure Active Directory authentication (like in this article: http://msdn.microsoft.com/en-us/magazine/dn463788.aspx ). However, when I call…
Yuriy Frolov
  • 301
  • 1
  • 3
  • 10