I have this simple code:
public void Run()
{
var invokerThread = new Thread(new ThreadStart(RunOnBackground));
invokerThread.Start();
}
private void RunOnBackground()
{
Trace.WriteLine("hi");
...
}
Unfortunately, when you run this code (from a third-party process), the thread really does not start. Either in the process explorer or in the VS debugger, I see that the thread has been created and its status is "Running".
The main thread of the STA apartment, and I tried both STA and MTA on the internal thread.
When I add to the method Run()at the end invokerThread.Join();, the thread starts. But again, this does not help.
What am I missing?
Edit: here is some more code hosting info -
Run() the method is called through COM interaction from a process that is also controlled by the executable assembly (the reason for using COM interaction is that all other components in the system are native).
RunOnBackground() , 10 20 , . , Trace. Run() , invokerThread.Start(); invokerThread - "Running" ( RunOnBackground() ).
invokerThread.Join() Run(), RunOnBackground() Join().