Jon Tackabury
Jon Tackabury

Reputation: 49289

Should I use the STA or MTA apartment state for a winforms window running on a new thread?

I need to open a window on a new thread, and I'm wondering if I should mark the thread as STA or MTA? I know that threadpool threads run as MTA, but they're typically not associated with any UI elements. Do winforms windows need to run as STA?

Upvotes: 0

Views: 3328

Answers (1)

Abdul Hfuda
Abdul Hfuda

Reputation: 1503

Take a look at the correct answer for this SO question, explains STA vs MTA very well.

I would recommend running it as STA if it is a winforms window regardless, otherwise you will run into undefined behavior territory even if you get it to compile.

Upvotes: 2

Related Questions