C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 1st, 2003, 05:15 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 7
STAThread

I have been looking through msdn an a few books an havent been able to find an explaination on what [STAThread] is or does.

Can someone explain to me its purpose or link me to a site that can help. thanks
__________________
Tewl

Reply With Quote
  #2  
Old June 6th, 2003, 07:27 PM
Tore Tore is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 1 Tore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I was looking for the same thing, and your post came out first on my Google search. Anyway, Apparently it is setting a the attribute for the Main method that defines the threading model for the form. I found this in VS.Net Help under "Form Class".

HTH,
Tore.

Reply With Quote
  #3  
Old July 5th, 2003, 01:46 PM
Malpass Malpass is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 6 Malpass User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Say you have a program that has a function that does some intesive stuff, such as a recursive math equation or a fibonacci etc.. and you want to update a progress bar or textbar with its progress, you'll notice that if you set a property in that functions thread it won't be received until the function has been completed, visavi no progress indicator. Thats where multithreading comes in, to do something like that you use another thread, I won't go into detail about that now.

STAThread stands for SingleThreadApplicationThread, meaning that your application is bound to its own single thread, in effect giving it more protection from accidental screw ups and such. It is also required for certain things like Dynamic menu items to work in Win98/ME.

Reply With Quote
  #4  
Old July 8th, 2003, 04:32 AM
dixanms dixanms is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 dixanms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
STAThread attribute

Quote:
Originally posted by Tore
I was looking for the same thing, and your post came out first on my Google search. Anyway, Apparently it is setting a the attribute for the Main method that defines the threading model for the form. I found this in VS.Net Help under "Form Class".

HTH,
Tore.


From MSDN

Indicates that the default threading model for an application is single-threaded apartment (STA).
,,,
Thread Safety
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Remarks
Threading models only pertain to applications that use COM interop. Applying this attribute to an application that does not use COM interop has no effect.

The startup threading model can be set to single-threaded apartment or multithreaded apartment. If it is not set, then the thread is not initialized.
...
dixan

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > STAThread


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT