/* added -> */ public void Dispose() { if (_notificationClient != null) { int hr = _realEnumerator.UnregisterEndpointNotificationCallback(_notificationClient); Marshal.ThrowExceptionForHR(hr); _notificationClient = null; } if (_realEnumerator != null) { Marshal.ReleaseComObject(_realEnumerator); } }
public MMDeviceEnumerator() { if (System.Environment.OSVersion.Version.Major < 6) { throw new NotSupportedException("This functionality is only supported on Windows Vista or newer."); } /* added -> */ _notificationClient = new MMNotificationClient(this); int hr = _realEnumerator.RegisterEndpointNotificationCallback(_notificationClient); Marshal.ThrowExceptionForHR(hr); /* <- added */ }
/* added -> */ public void Dispose() { if (_notificationClient != null) { int hr = _realEnumerator.UnregisterEndpointNotificationCallback(_notificationClient); Marshal.ThrowExceptionForHR(hr); _notificationClient = null; } if (_realEnumerator != null) Marshal.ReleaseComObject(_realEnumerator); }