Very simple System.MTAThread question

  • Thread starter Thread starter Erik
  • Start date Start date
E

Erik

Where is the "MTAThread()" method?

I'm writing a service in VB.Net. Being of a curious nature, I looked
at the generated code, which has the following:
<MTAThread()> _
Shared Sub Main()
' stuff deleted
End Sub

I've read all about the MTAThreadAttribute and COM interop; I
understand the need for the MTA thread attribute on the entry point to
a service. That's not my question. My question is just: where is the
MTAThread() method? If this is an object's constructor, why is the
MTAThread object not documented anywhere? If it's a method on another
object, what object?

Or maybe I'm just not meant to know, and that's what I get for
spelunking through generated code.
 
I've read all about the MTAThreadAttribute and COM interop; I
understand the need for the MTA thread attribute on the entry point to
a service. That's not my question. My question is just: where is the
MTAThread() method? If this is an object's constructor, why is the
MTAThread object not documented anywhere? If it's a method on another
object, what object?

It's not a method, it's an attribute constructor. Attributes are very
special kind of entities in .NET. MTAThread() is the constructor of the
class MTAThreadAttribute (yes, it sounds weird that the constructor looks
like it has a different name than its class but as i said, attributes are
"special". They are actually processed by the preprocessor in a very
particular way). Google has plenty of information about .NET attributes if
you're feeling curious.
 
Back
Top