The symptom I'm trying to resolve is that my XNA application will not restore some of the time after being being minimized. I click the minimize button, but when I click on my application's entry in the task bar, the application does not resume - it stays minimized. Furthermore, I hear a Windows "ding" sound effect play.
If I click on the application repeatedly it sometimes resumes. I've found that if my application has less processing time in its every-frame Update call, then the problem is harder to reproduce. If I add this:
System.Threading.Thread.Sleep(100);
then it's almost impossible to have the application resume.
I've found that if I remove [STAThread] on Program.Main, it always resumes perfectly; however, I use winforms OpenFileDialog's which require STAThread to be set on the Main method so I can't get rid of that attribute.
Any thoughts as to why this might be happening, and if there's a way to both use STAThread and have the application properly resume?
Edit: Internally my application is using ThreadPool.QueueUserWorkItem, and the presence of that is what is causing this. Does this mean that ThreadPool.QueueUserWorkItem should not be used in a STAThread application?