Skip to main content

Input in XNA is not thread-safe and must be handled on the main thread. Simple as that.

Move your input polling to the main thread.

This is the thread safety of the XNA Framework (info is from XNA 3.1, but is probably still applicable):

  • GraphicsDevice is somewhat thread-safe

  • Cannot render from more than one thread at a time

  • Can create resources and SetData while another thread renders

  • ContentManager is not thread-safe

  • Ok to have multiple instances, but only one per thread

  • Input is not threadable

  • Windows games must read input on the main game thread

  • Audio and networking are thread-safe

Source: "Understanding XNA Framework Performance""Understanding XNA Framework Performance" by Shawn Hargreaves (Slide 27)

Input in XNA is not thread-safe and must be handled on the main thread. Simple as that.

Move your input polling to the main thread.

This is the thread safety of the XNA Framework (info is from XNA 3.1, but is probably still applicable):

  • GraphicsDevice is somewhat thread-safe

  • Cannot render from more than one thread at a time

  • Can create resources and SetData while another thread renders

  • ContentManager is not thread-safe

  • Ok to have multiple instances, but only one per thread

  • Input is not threadable

  • Windows games must read input on the main game thread

  • Audio and networking are thread-safe

Source: "Understanding XNA Framework Performance" by Shawn Hargreaves

Input in XNA is not thread-safe and must be handled on the main thread. Simple as that.

Move your input polling to the main thread.

This is the thread safety of the XNA Framework (info is from XNA 3.1, but is probably still applicable):

  • GraphicsDevice is somewhat thread-safe

  • Cannot render from more than one thread at a time

  • Can create resources and SetData while another thread renders

  • ContentManager is not thread-safe

  • Ok to have multiple instances, but only one per thread

  • Input is not threadable

  • Windows games must read input on the main game thread

  • Audio and networking are thread-safe

Source: "Understanding XNA Framework Performance" by Shawn Hargreaves (Slide 27)

Source Link
Andrew Russell
  • 21.3k
  • 7
  • 58
  • 104

Input in XNA is not thread-safe and must be handled on the main thread. Simple as that.

Move your input polling to the main thread.

This is the thread safety of the XNA Framework (info is from XNA 3.1, but is probably still applicable):

  • GraphicsDevice is somewhat thread-safe

  • Cannot render from more than one thread at a time

  • Can create resources and SetData while another thread renders

  • ContentManager is not thread-safe

  • Ok to have multiple instances, but only one per thread

  • Input is not threadable

  • Windows games must read input on the main game thread

  • Audio and networking are thread-safe

Source: "Understanding XNA Framework Performance" by Shawn Hargreaves