Jump to content
  • Advertisement
Sign in to follow this  
Stormtrooper

[SlimDX] Device Lost Handling

This topic is 3711 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get my program to handle lost devices(following the Sample as an example) I have this code in the game loop:
            if (_device.Present() == ResultCode.DeviceLost)
                _deviceLost = true;
Now when the device is lost, it throws an exception and the program stops running. In the Samples, it does not throw an exception and everything keeps going on its marry way. How do I stop it from throwing an exception and keep going?

Share this post


Link to post
Share on other sites
Advertisement
SlimDX is automatically set to throw exceptions on any failure result. There are a few ways to customize this behavior. First, you could set the Configuration.ThrowOnError property to false, and then none of the methods will throw exceptions, but will instead return result codes for you to test. This is generally not recommended, since it's very difficult and tedious to be sure you test the result of each method call.

The second way would be to customize the set of results that will trigger an exception. This is the method that the samples use. Simply add a result watch connecting the result code with the action you wish to take. For example:


Configuration.AddResultWatch(ResultCode.DeviceLost, ResultWatchFlags.AlwaysIgnore);
Configuration.AddResultWatch(ResultCode.WasStillDrawing, ResultWatchFlags.AlwaysIgnore);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!