I keep looking around to try and figure this out. I keep seeing code with something like [STAThread] on a line by itself.
Now, I have figured out that it sets the type of apartmenting you can do. And you seem to use it like the using namespace statements to define if you are going to hae a sta or a mta, but where in the world does the syntax for this statement come from Is this strictly a COM feature in which it overloaded the [] operator
Just wanted to make sure I didn't miss some new language element that I may need.
Also, I seem to have gathered that you only need to mark things as STA or MTA using this feature if you are going to be interfacing with a COM DLL If you stay in the .NET you can ignore this

OK, What is with the statements enclosed inside [] operator regarding threading?
BruceJohnson
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant C++: C# to C++ Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up VB.NET code
flyonthewall
Bravo2007
These are Attributes. There are several kinds of attributes including those that you define yourself (look into the System.Reflection namespace). In the case of STAThread or MTAThread, the CLR will set the Apartment type of the main thread accordingly -- the same as calling Thread.SetApartmentState. In the case of STAThread, COM is initialized for the thread with a call to OleInitialize() which enables using drag-and-drop, the clipboard and other features. The best thing to do is always make a WinForms app an STAThread.
jporto
Jeffrey Baker
Attributes are meta-data about the entity you apply the attribute to.
Examples are:
[Obsolete]
[Serializable]
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up VB.NET code
mjf_29
TeamWild
See the below following links that might help:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/vcattrib/html/vcrefMethodAttributes.asp
http://msdn.microsoft.com/library/default.asp url=/library/en-us/vcattrib/html/vcrefattributesbyusage.asp
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnguinet/html/drguinet3_update.asp
Hope this helps!
Thanks,
Ayman Shoukry
VC++ Team
YohanAudoux
C++/CLI is VC++ 2005
You've got it - not having to make the 2003 - 2005 transition makes your life easier.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant C++: C# to C++ Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up outdated VB.NET code