section

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()
{
 
G

Göran Andersson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top