Question about threads and win32 api's ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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!
 
O.k., thanks. It's not a com object, just an api, but your info
may be useful in future ....

tt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top