private void ReleaseHandle() { Monitor.Enter(this); try { this.handleCount--; if (this.handleCount == 0) { ScpCommands.Close(this.handle); this.handle = IntPtr.Zero; } } finally { Monitor.Exit(this); } }