> No, you should never init a UI thread for MTA, nor should you create
> instances of STA objects on MTA threads.
OK, thanks
> All you have to do is create a background thread and initialize it to enter a
> STA before you start the thread. After that you simply create an instance of
[quoted text clipped - 4 lines]
> t.IsBackground = true;
> t.Start();
Thank you. Do you really mean that from this thread I can access my COM
object that were created in the main thread without having to marshall
the interface?
> Just take care when updating the UI from this thread, you have to use
> Control.Invoke or Control.BeginInvoke to do so.
Yes thanks.

Signature
----
http://michael.moreno.free.fr/
Willy Denoyette [MVP] - 08 Jun 2005 16:02 GMT
Inline **
Willy.
>> No, you should never init a UI thread for MTA, nor should you create
>> instances of STA objects on MTA threads.
[quoted text clipped - 13 lines]
> object that were created in the main thread without having to marshall the
> interface?
** Yes you can, but that doesn't mean you should create the object on the
Main UI thread, if you only intend to call methods from the background
thread you better create the COM object on this thead.
If you are calling methods on both you can create an instance on both as
well, so each will have his own instance, no marshaling needed.
If however, you create an instance on the Main thread and pass a reference
to it to the background thread, the CLR will automagically marshall the
Interface pointer for you (tout gratuit).
>> Just take care when updating the UI from this thread, you have to use
>> Control.Invoke or Control.BeginInvoke to do so.
>
> Yes thanks.
Michael Moreno - 08 Jun 2005 17:00 GMT
> ** Yes you can, but that doesn't mean you should create the object on the
> Main UI thread, if you only intend to call methods from the background thread
> you better create the COM object on this thead.
yes I agree.
> If however, you create an instance on the Main thread and pass a reference to
> it to the background thread, the CLR will automagically marshall the
> Interface pointer for you (tout gratuit).
That is the best news I have heard for a long time!!!!
Thanks a lot for your help.

Signature
----
http://michael.moreno.free.fr/