private void Dispose(bool disposing) { if (_disposed) return; _disposed = true; int count = Interlocked.Decrement(ref s_totalInstanceCount); if (count == 0 && s_needRelease && disposing) { _client.EndSession(DebugEnd.ActiveDetatch); _client.DetatchProcesses(); } // If there are no more debug instances, we can safely reset this variable // and start releasing newly created IDebug objects. if (count == 0) s_needRelease = true; }