Sign in to follow this  
Barguast

Managing IResettable-s

Recommended Posts

Barguast    181
Okay, I probably doesn't matter much but I'm wondering about what the best way to handle IResettable instances in SlimDX is. At the moment, I have a class which wrap the Device class to automatically detect and recover from device resets. At the minute it provides two events - LostDevice and ResetDevice - which I can subscribe to in order to call the matching methods of my IResettable instances. However, I'm considering just maintaining a list internally which can be added to and removed from as IResettable instances are created and destroyed. It might be easier to code with given that I won't need to have two event handlers to handle this, rather I can just call a method to start managing, and another to stop. Or perhaps there is another way to handle this? What do you think? :p Thanks!

Share this post


Link to post
Share on other sites
jpetrie    13162
SlimDX's ObjectTable already has such a list. You could iterate the object table and look for objects implementing the interface if you really want to take that approach (ObjectTable.Objects.Where( o => o is IResettable) or whatever).

If you maintain your own list(s) you'll avoid the cost of the is check and the wasted time iterating over non-resettable objects. The point of the IResettable interface was to allow for these sorts of generic reset handling.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this