By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,571 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,571 IT Pros & Developers. It's quick & easy.

set my thread to enter STA

P: n/a
hi.
i have a thread ,with form.
and there is no COM object when he runs.

can i still set this thread to run as STA ,even, if i dont use com object ?
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
can i still set this thread to run as STA ,even, if i dont use com object ?


Yes.

For the main thread you don't have to do it, since Main() in VB.NET
implicitly is given the STAThread attribute.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #2

P: n/a
well , the important thing i want to know :

in code the thread.currentthread.apartmentstate is STA , (when i read the
value)
now, as i said, i dont use com object in that thread.

this thread is actcually running in STA ?
cause i can see other thread's can access objects created by the this
thread,
and its not act like STA.

what wrong here ?

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
can i still set this thread to run as STA ,even, if i dont use com object
?
Yes.

For the main thread you don't have to do it, since Main() in VB.NET
implicitly is given the STAThread attribute.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 20 '05 #3

P: n/a
I did some research into this awhle back. <STAThread> attribute only
applies to COM exposed objects. Otherwise, the attribute is ignored.

I think the help file states that. Wish I had some more info for ya.

-CJ
"Daylor" <ro******@hotmail.com> wrote in message
news:bu**********@news2.netvision.net.il...
well , the important thing i want to know :

in code the thread.currentthread.apartmentstate is STA , (when i read the
value)
now, as i said, i dont use com object in that thread.

this thread is actcually running in STA ?
cause i can see other thread's can access objects created by the this
thread,
and its not act like STA.

what wrong here ?

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
can i still set this thread to run as STA ,even, if i dont use com
object ?

Yes.

For the main thread you don't have to do it, since Main() in VB.NET
implicitly is given the STAThread attribute.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.