473,396 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Question about threads and win32 api's ?

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.
Nov 21 '05 #1
2 1025
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.

Nov 21 '05 #2
O.k., thanks. It's not a com object, just an api, but your info
may be useful in future ....

tt
"Bonj" <Bo**@discussions.microsoft.com> wrote in message
news:D2**********************************@microsof t.com...
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.


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Martijn | last post by:
Im writing a windows-based program that uses multiple threads. In java, there exists a standard class Thread, but in c++ there is no such thing. Could anyone tell me the easiest way to create a...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
12
by: Mike | last post by:
I have posted this before, but no one responds, so here it goes again. I think my question is intimidating people and I have no idea why?!? This is not a new concept. You can do this with other...
3
by: bygandhi | last post by:
Hi - I am writing a service which will check a process and its threads for their state ( alive or dead ). The process has 5 .net managed threads created using thread.start and each have been...
2
by: Tony Johansson | last post by:
Hello!! When you for example use C++.net environment for develop an GUI application does this mean that you doesn't use win32 API as much as when you had visual studio 6.0 because of the large...
25
by: MuZZy | last post by:
Hi, I'm currently rewriting some functionality which was using multithredaing for retrieving datasets from database and updating a grid control. I found that the grids (Infragistics UltraGrid,...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
6
by: Stephen Torri | last post by:
I am trying to produce a singleton class that I can use throughout my library to write tracing information to a file. My intent was to design such that someone using the library in its debug mode...
8
by: JackC | last post by:
Hi, I am trying to get posix threads working from within an object, heres some code: int NConnection::TheadControl() { int thread_id; pthread_t new_connection;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.