section

  • Thread starter Thread starter Jung, William
  • Start date Start date
J

Jung, William

What is the [STAThread] means below?
Is this a comment only?

static class Program
{

private const int ERROR_EVENTLOG_FILE_CORRUPT = 1500;
private const int ERROR_EVENTLOG_CANT_START = 1501;
private const int ERROR_LOG_FILE_FULL = 1502;

/// <summary>
/// The main entry point for the application.
/// </summary>
//[MTAThread]
[STAThread]
static void Main()
{
 
What is the [STAThread] means below?
Is this a comment only?

static class Program
{

private const int ERROR_EVENTLOG_FILE_CORRUPT = 1500;
private const int ERROR_EVENTLOG_CANT_START = 1501;
private const int ERROR_LOG_FILE_FULL = 1502;

/// <summary>
/// The main entry point for the application.
/// </summary>
//[MTAThread]
[STAThread]
static void Main()
{

It's an attribute. It's used to specify settings that the compiler can
use. In this case it specifies the COM threading model for the program.

Look up the STAThreadAttribute class in the documentation for more
informaton.
 
Back
Top