   MDX - Device.Dispose takes a LONG time
  When shutting down my MDX application, calling Device.Dispose() is taking a very, very long time (32 seconds last run).  Is there any reason for this?  What should I do to speed it up?  Any ideas will be helpful since I have no clue how to even begin solving this.Thanks in advance.   
  You have some resource (texture, cubemap, shader, etc) which you havent disposed of. You need to dispose of everything before your app ends, or the garbage manager will need to track down and dispose of every resource still in memory.   ;  Make sure you do: "Device.IsUsingEventHandlers = false";Basically, keep this static value at false until you need it.Graphic Item Initialization Example:Device.IsUsingEventHandlers = true; CurrentDevice.DeviceLost+= new EventHandler(OnInvalidate);CurrentDevice.DeviceReset+= new EventHandler(OnRestore);CurrentDevice.Disposing   += new EventHandler(OnDispose);Device.IsUsingEventHandlers = false; Why, you ask?  Because otherwise it creates a huge chain of events that have to unwind every time you Dispose().   ;  I support Cadef's answer, check whether you have some resources that you haven't disposed of yet. Basically you should dispose of your device last.   ;  Thanks.   ;  Funny, i got the same problem.I solved the problem by let crashing the app with the end-Statement.It´s quite fast.;  Read about this on Tom's blog. As other have alluded you are likely creating MDX objects which are automatically hooking into the MDX event handling. This means that even though you let them go out of scope and expect them to be tidied on the next GC they will not be GC'd until the end and if the creating happens in your render loop there is probably thousands of them. Its not sufficient to let most MDX object go out of scope you have to call dispose on them or use using {} properly.The AutoEventHandler will stop the big delay at the end but it doesn't solve the fundamental problem that you are not disposing things properly. Since almost all the MDX objects wrap native resources they have to be disposed. Sure the GC will tidy everything up for you EVENTUALLY but disposable objects that are not disposed by you explicitly take 2 GC cycles to be tidied up (see below) and are always promoted to the next level of GC which is a bad thing.(1st GC finds its not used but since there is a finalizer it adds it to the finalizer queue and promotes the object to GC1. The finalizer thread eventually calls the finalizer and disposes the object. Next time there is a GC1 the object will be removed from memory.);  ZMan, one of the reasons why we see this shutdown problem over and over again is IMHO a big design flaw in the current MDX version.Most people will have no problem to call Dispose for objects they have created with a “new” as this is common in the managed world.  Calling Dispose for objects that are build with a static “Fromxyz” or “Createxyz” method are less common but still something C# and VB developers can understand.The big problem are IMHO all the Get* methods that returns other DirectX objects like GetSurfaceLevel or GetBackBuffer. Most people don’t know and I don’t see it in the docs that you have to dispose these objects too. If you don’t do this every time you request such an object an additional one is added to the event chain of the parent object. If you work without the default event handling and forget to dispose such objects it could be even worse because the managed objects will hold references to the unmanaged world. As long as they are not collected from the GC there is a high possibility that you are not able to reset the device.I must confess that during the design of my managed Direct3D 10 layer I have done the same mistake first too. But then I changed the whole stuff to make sure that there will always only one instance of a managed object for every unmanaged one.  With this and some other changes it was possible to make sure that the user need only call Dispose for instances that were created with new. Even if the Dispose is not called the GC will find the unused objects and removed them.   