Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a game in XNA, which has an inbuilt level editor. To facilitate this I want use the FileOpenDialog from Winforms. I followed the instructions as per this answer. This involves setting the [STAThread] attribute on my Program class.

Does using STAThread have any negative implications? Meaning will it cause worse performance or limit me in some way?

Hard to compose a definitive answer but I think it only affects cross process communication so it shouldn't have a negative impact. More answers: stackoverflow.com/questions/165316/stathread-and-multithreading –  Roy T. Nov 20 '12 at 9:35

1 Answer 1

up vote 1 down vote accepted

The STAThread attribute is used to indicate to COM that the application should use a single-threaded apartment (STA). This only affects COM objects, and is only required as certain dialogs that use COM (such as the FileOpenDialog) need the the correct threading model to be specified.

To my knowledge very little (if any) game development will make use of COM with the exception of Windows Forms dialogs and so this is won't have any impact, its simply required for those dialogs.

If you do make use of COM objects then you may want to look into COM threading models to fully understand the implication of this setting, however the short version is that in a STA all COM methods will be run on a single thread (the UI thread in this case) even if it was invoked on another thread.

Update: DirectX is available as a set of COM objects, however I'm not sure what threading model they require.


Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.