Randal Greene

We have a C# app that uses a render thread separate from the main thread. Our DeviceLostException handling works for the case where the user hits ctrl-alt-del, then cancels it. However, when the user hits ctrl-alt-del then locks the PC then hits ctrl-alt-del again and enters their password, the app returns with a DeviceLostException in the main thread.

We assume the main thread is involved because the device Reset call is inside an Invoke. The call stack for the main thread in the debugger shows only one line of code (Application.Run) with the previous line being external code.

Handling DeviceLostException in our main thread does not appear to be an option because our only recourse would be to execute another Application.Run on our main form!

Is this a common situation With a common solution

Thanks in advance...



Re: Game Technologies: Graphics DeviceLostException

qrli

From SDK doc:
"Direct3D is designed so that the methods Reset, CreateDevice, TestCooperativeLevel, or the final Release of IDirect3DDevice9 can only be called from the same thread that handles window messages."




Re: Game Technologies: Graphics DeviceLostException

Randal Greene

Thanks for the input qrli. Our calls to Reset and TestCooperativeLevel now all happen in an Invoke back on the main thread, and we always catch DeviceLostException on these calls. However, after starting and stopping the screen saver using ctrl-alt-del, we get an unhandled DeviceLostException back in our Main function on Application.Run. When we attempt to debug this by putting a break on TestCooperativeLevel and Reset calls, all works fine!

Any more thoughts greatly appreciated...





Re: Game Technologies: Graphics DeviceLostException

qrli

It seems like a race condition. Some thread is accessing D3D objects before TestCooperativeLevel is called. But the strange point is DeviceLostException comes out of Application.Run() of the main thread. So if it is true, it's possible that the exception comes from a callback from unmanaged code, like the include interface implementation for Mesh objects. Or the info may be wrong, the debuger stopped there but the exception point was in the other thread, so you need to pick other threads in the thread window to see where they stopped.