From the MSDN article on STAThread:
Indicates that the COM threading model for an application is single-threaded apartment (STA).
(For reference, that's the entire article.)
Single-threaded apartment... OK, that went over my head. Also, I read somewhere that unless your application uses COM interop, this attribute actually does no...
I am a newbie to WPF and have a couple of questions about WPF and Windows Forms integration.
I have an existing Visual C# Windows Forms application. I would like to integrate it with a WPF window, that can be shown on a button click. This was not possible as WPF expects the calling thread to be a STAThread and by default WinForm assu...
I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue.
I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTask for EmployeePresenter) are...
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
|> ignore
What to do in the case the windowsProcess requires a STATHREAD? Is this possibl...
Some background:
I get the following exception in my code below.
ThreadStateException : ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
The Main() method is marked with the [STAThread] attribute.
The app is supposed to start up without a wi...
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 means the thread running the workflow has to be STA.
In 3.0, you could do some magic (I didn'...
I have created a Windows Service that will be calling out to some COM components, so I tagged [STAThread] to the Main function. However, when the timer fires, it reports MTA and the COM calls fail. How can I fix this?
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using System.Timers;
n...
I would like to test an app that uses the Clipboard (WindowsForms) and I need the Clipboard in my Unittests also. In order to use it, it should run in STA mode, but since the NUnit Testfixture does not have a main method, I don't know where/how to annotate it...
Thanks!
...
I'm calling Process.Start, but it blocks the current thread.
pInfo = new ProcessStartInfo("C:\\Windows\\notepad.exe");
// Start process
mProcess = new Process();
mProcess.StartInfo = pInfo;
if (mProcess.Start() == false) {
Trace.TraceError("Unable to run process {0}.");
}
Even when the process is closed, the code doesn't respond ...
I wrote a custom table class for Slim that lets users write commands that are used to run automated tests. All commands are now working, except for one that relies on a certain call that has to be made in an STA thread. I was able to solve this issue in Fit by adding
STA
to the suiteConfig file. However, it looks like adding that to t...