Suppose I have private static MyClient _myClient that opens a connection to an external server. It implements IDisposable. The 'client' is created on first use:
if (_myClient == null)
_myClient = new MyClient (_myClientHostAddress);
I'm assuming once the above statement is executed the class loader puts the instance _myClient on the application stack.
Is this usage correct:
using (_myClient)
and if so what happens to _myClient when the using statement is out of scope?
Is _myClient marked for gc or popped directly off of the application stack by IDisposable?
If marked for garbage collection does the garbage collector pop it off the stack?
Thanks!