Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STA multithreaded ? 1

Status
Not open for further replies.

Fursten

Programmer
Dec 27, 2000
403
PT
Hi,

I have a doubt about some definitions...

To say that a component is multithreaded... is the same as to say that it is STA (Single threaded apartment)?

In my opinion, they are distinct concepts, however, in visual basic, every component (single threaded component or multithreaded component) is always STA. Well the component is not STA, but the type of the apartments it creates are STA (every apartment will always have just one thread to it...).

AM I understanding this concepts right?

Thank you

Sérgio Oliveira
 
Yes, VB only does apartment threading.

It is possible to break this model using API calls, but not with 100% reliability.
 
Hi,

Strongm my doubt is not about if VB only implements or not apartment threading. I´m sure that vb only uses it, too. sorry if I didn´t explained myself very well.

My real question is: Does VB components can be multithreaded? If yes, then I think that to say that a component implements an STA model is NOT equivalent to say that the component is single threaded... Are you understanding my doubt? :)

In other words, it seems that we can have a com component( for instance to a dll) single threaded (if in project/properties/threading model we choose single threaded) or multithreaded if in the same location we say it is apartment threaded. Despite the threading model of the component, all the threads only have one apartment associated with it (so the apartment is single threaded despite the component itself be multithraded)


"so the apartment is single threaded despite the component itself be multithraded" --> Here are my point: For what i have read until now, it seems that the threading model of a component is one thing... and the threading model of an apartment is another thing... in a way that we can have a multithreaded component with a single threaded apartment...

Please help me on this because I think the literature about this is not very well writen (at least for a VB programmer!).

Thank you

Sérgio Oliveira

 
Well, I guess it depends on your viewpoint. As I said before, VB only does apartment threading. However, using V you can produce servers that provide multiple instances of objects. Each object is STA, but you end up with multiple apartments, so you do have multi-threading of a sort. Because each object instance is still single-instance apartment threaded, you have a bunch of restrictions on what you can do.

The following link may be of some assistance:
 
Ok, that was my point too.

Thanks

By the way, just one more question:

In an ActiveX EXE we are able to have some control on the number of threads we create... but what about a Standard EXE? If I write a Standard exe withou force with code a new thread... it means that all standard exe are single threaded? (in other words, only create one thread)

Thank you again!

Sérgio Oliveira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top