I have a Singleton class that controls the connection to an external device. The idea of my application is that I need the external device to be displayed all the time when the application is live.
Singleton has the following features:
- Initialization, locate the device during application launch
- interact with an external device, please note that this may apply to multiple assemblies at multiple points.
- Close the connection when the application terminates.
In the last part, I think about putting the code inside the method Disposefor the singleton class to ensure that the resource will always be cleared when it closes. But since I use Singleton, and since the lifespan of one element will be terminated only after the application exits, there is no need to explicitly close the connection in Dispose, since the connection will still be closed.
So the question is, should I enclose the closed connection code inside the method Dispose?
source
share