exception handling - DeviceLostException during CTRL ALT DEL in Direct3D using C# -


i using microsoft.directx , microsoft.directx.direct3d references drawing on form. while running program , user presses ctrl alt del in windows xp , brings "windows security" form, when returning form, devicelostexception thrown , when trying handle exception there seems no way back.

i have done little research matter , have tried several coding solutions.

        try         {              _d3ddevice.present();                          }         catch          {             devicelost = true;         }          if (devicelost)          {             attemptrecovery();         }          this.invalidate();         readkeyboard();          base.onpaint(e);                }          private void attemptrecovery()     {         try         {             _d3ddevice.testcooperativelevel();         }         catch (devicelostexception)         {             application.exit();         }         catch (devicenotresetexception)         {             try             {                 _d3ddevice.reset(_params);                 devicelost = false;                  initgraphics();                 camerapositioning();                 vertexdeclaration();                 indicesdeclaration();                      }             catch (devicelostexception)             {             }         }     } 

when program calls testcooperativelevel(), said online if catches devicelostexception again there no point in trying reset device.

what can reset device , continue drawing in form?

2 things in 4 points :

  • you shouldn't use microsoft.directx, it's deprecated since long, long time. check out slimdx or sharpdx instead.
  • in order re-create device, first have wait until device can restored
  • when device can restored, have free video-memory objects, , recreate them.
  • you call reset method.

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -