Disposal of resources when app closes

Nov 17, 2008 at 2:54 PM
I'm sorry if this is documented somewhere but I couldn't seem to find it in the documentation or the discussions.

What are some ways or the "prescribed" way of disposing of objects like streams and such when the app is shut down.

The situation is this.  I have a serial device which I interact with through the SerialPortApi.  It is just a magnetic stripped card reader.  It publishes two events, one for a good swipe and one for a failed swipe.  I'm not sure how to get the object to dispose when the program is shutting down. 

None of the other modules interact with it.  I instantiate a class and register the instance in the initialize method of the Module and it reads the cards the way it is supposed to.  However, since I can't dispose of it I am running into problems when the program is restart.

Nov 17, 2008 at 3:24 PM

I looked in the Unity documentation and found the IUnityContainer.Dispose method which is exactly what I was looking for.