
Stop Statement | 455
The Language
Reference
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
STAThread Attribute
Class
System.STAThreadAttribute
Applies To
Method
Constructor
New( )
Properties
None defined
Description
The <STAThread> attribute indicates that the application to which the program element
belongs uses the single-threaded apartment model for COM interop. The attribute
should be applied to the application’s Main method or subroutine. This attribute only
applies to applications that use COM interop.
The
<STAThread> attribute is similar to setting a System.Threading.Thread object’s
ApartmentState property to ApartmentState.STA. The difference is that the
<STAThread>
attribute creates a single-threaded apartment from startup, while setting the property
does it only from the point that the property is set.
See Also
MTAThread Attribute
Static Statement
Description
The Static statement is used at the procedure level to define a local variable with a
value that is retained for the lifetime of the object in which it appears, even when the
variable goes out of scope (that is, even when the procedure’s code is not currently
being executed).
The
Static statement is actually a variation of the Dim statement. For more informa-
tion on the syntax and use of the
Static statement, see the Dim Statement entry
elsewhere in this chapter.
See Also
Dim Statement ...