I am using multithreading in my XNA application and run my update logic s in a update thread(witch is a worker thread) and rendring is being done by main thread, now the problem is updation is required there on keyboard event, and key Board handling can be done only in main thread.

Note that my application was single threaded and I have implemented threading, synchronization is being done by 'data partitioning', both the threads are working correctly, except my keyboard is not working..

if any one have any suggestion or example, please allow me to know.

thanx in advance.


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)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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