/*** IDisposable impl ***/ void IDisposable.Dispose() { if (_disposed) { return; } // Attempt to unregister all of our hotkeys foreach (var hk in _hotkeys) { if (!UnregisterHotKey(_msgWindow.Handle, hk.Key)) { throw Helpers.LastWin32Exception(); } } _hotkeys.Clear(); _msgWindow.Dispose(); // Next call to [Retrieve] will create a new registrar. _singleton = null; _disposed = true; }
/// <summary> /// Retrieves a <see cref="WindowsHotkeyRegistrar"/> instance, /// creating one if one does not already exist. /// </summary> /// <returns> /// A hotkey registrar for the Windows API. /// </returns> public static WindowsHotkeyRegistrar Retrieve() { return(_singleton ?? (_singleton = new WindowsHotkeyRegistrar())); }