473,387 Members | 1,441 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,387 software developers and data experts.

set my thread to enter STA

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
3 1343
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Andy Chang | last post by:
Hi, If I have this function void DoSomething(int& index) { ::Sleep(10000); DoSomethingWith(index); } Is the variable index thread safe? Meaning that if I call this from two
8
by: Maloney | last post by:
Exit thread in C#CF. I'm createing a thread and setting a class object for when to exit. Before creating the thread i check if the thread is running, if so set the flag to exit the thread. ...
8
by: Mountain Bikn' Guy | last post by:
I'm using async delegate calls. I would like to re-enter my initial thread after the callback. (I'm not using UI controls, so Control.Invoke is not the solution.) How can I manually implement...
4
by: denton | last post by:
I want to read a line from the textbox just like a console window. The called thread will not allow me to enter keys when I call Join. I have stuck on this problem for 2 weeks: private void...
10
by: Curious | last post by:
Hi, I have a worker thread running, where basically its operation is to execute in an infinite loop. Now, when I am suspending this thread, the CPU usage time is still remaining 100%. What...
0
by: fiefie.niles | last post by:
I am having problem with thread. I have a Session class with public string variable (called Message) that I set from my Main program. In the session class it checks for the value of Message while...
5
by: fniles | last post by:
I am having problem with thread. I have a Session class with public string variable (called Message) that I set from my Main program. In the session class it checks for the value of Message...
8
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I have an application with several BackgroundWorker threads. I hoped I'd be able to just type backgroundworker1.Name = "bw1"; but I don't see a name property. Any thoughts on how to name a...
2
by: Chameleon | last post by:
Why this strange output? Why so many d'tor calls? The code: ---------------------------------------------------------- #include <cstdio> #include <boost/thread/thread.hpp> class A {
29
by: NvrBst | last post by:
I've read a bit online seeing that two writes are not safe, which I understand, but would 1 thread push()'ing and 1 thread pop()'ing be thread-safe? Basically my situation is the follows: ...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.