I had an issue in a program recently which called dtspkg.dll, the DTS Package
Object library (a COM DLL).
The thing that actually did the calling was a worker thread.
When the DTS started, it would work fine for a small number of rows, but
when it got to about 100,000 rows it would crash spectacularly.
I wouldn't have found out what was wrong with it in a million years until I
posted a question here and somebody said it was because I needed to change
the threading model property of the thread to STAThread (out of a possible
STAThread, MTATHread and Unknown).
So the lesson from this is only ever call an STA-threaded COM DLL (which
most apparently are) on an STAThread thread.
Calling APIs though... I believe you can do in any thread whatever its type,
although I may be wrong!
"tt" wrote:
Hello all,
I need to call a win32 api and I also need to have a worker
thread in my program. Is there something I should be
carefull of, as in the documentation for 'thread' it reads
"ApartmentState:
Gets or sets the threading model used for a particular thread.
Threading models are important when a thread calls unmanaged code."
Tia.