I have an XNA application that renders onto a second monitor (adaptor 1), at regular intervals it takes a screenshot of itself and stores it as a Texture2D.
As this application launches it also shows a Windows Form with a panel. This panel is supposed to be drawn on by a seperate GraphicsDevice, and displays the Texture2D.
The problem I am having is that as I run this code in the Windows form to create the GraphicsDevice:
mainDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, panel1.Handle, pp);
I get a DeviceLostException. The standard advice in this case is to catch the exception, sleep the thread for a few seconds and retry, but this just puts me in an infinite loop.
I suspect this is because my XNA class is using the hardware at the same time and that I am thinking about this the wrong way. But I can't find any documentation on how I should be doing this correctly.
Any help would be much appreciated.