thread STA (Single Thread Apartment) after copy CTRL-C

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
beauto
Posts: 5
Joined: Mon Feb 03, 2014 10:01 am

thread STA (Single Thread Apartment) after copy CTRL-C

Post by beauto »

hi,

i have a bug when i try to copy (after select a line from a datagrid) :

The current thread must be STA (Single Thread Apartment) before OLE calls can be made.

i don't find where or what i can do for resolution of this exception !

thank

AMitchneck
Posts: 137
Joined: Mon Jun 11, 2012 2:10 pm

Re: thread STA (Single Thread Apartment) after copy CTRL-C

Post by AMitchneck »

beauto,

It's hard to diagnose your problem without further information. Is the OLE managed in a thread you created?

You need to set the threads apartment state before it is started (see http://msdn.microsoft.com/en-us/library ... 00%29.aspx). By default, threads will use MTA if not explicitly set before starting the thread.


There are two types of apartment models that can be used for COM objects (such as OLE) they are Single-threaded Apartment model (STA) and Multi-threaded Apartment model (MTA). For the most part, what it breaks down to is synchronization so the COM object doesn't end up in some sort of limbo state. This is especially true for OLE objects which are graphical in nature.

For more information, look at:
http://support.microsoft.com/kb/150777
http://msdn.microsoft.com/en-us/library/ms809971.aspx
Adam M.
Controls Engineer
FlexEnergy

beauto
Posts: 5
Joined: Mon Feb 03, 2014 10:01 am

Re: thread STA (Single Thread Apartment) after copy CTRL-C

Post by beauto »

it's not a real problem because it's only on simulation and not on panel ( not possible to select a line and copy)

perhaps that's come by another scriptcyclique which run ever 300ms and the application become multithread ....

thank for your interest

Post Reply