• Advertisement
Sign in to follow this  

Managing IResettable-s

This topic is 2934 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement