private void UnregisterFilter() { if (_filter != null) { Application.RemoveMessageFilter(_filter); _filter = null; } }
private void RegisterFilter() { if (_filter == null) { // Check that caller has permission to access unmanaged code new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); try { _filter = new SeparatorMessageFilter(this); Application.AddMessageFilter(_filter); } finally { // Always revert the assertion made above CodeAccessPermission.RevertAssert(); } } }