public IDisposable Register(IVirtualDesktopNotification notification) { var type = this.ComInterfaceAssembly.GetType("VirtualDesktopNotification"); var listener = Activator.CreateInstance(type) as EventListenerBase ?? throw new Exception($"{nameof(EventListenerBase)} inheritance type is not found in the COM interface assembly."); listener.Notification = notification; listener.Factory = this._factory; var dwCookie = this.InvokeMethod <uint>(Args(listener)); return(Disposable.Create(() => this.Unregister(dwCookie))); }
public static uint RegisterVdmNotification(IVirtualDesktopNotification notification) { try { s_notificationService.Register(notification, out uint cookie); return(cookie); } catch (Exception e) { Logger.Instance.Log(LoggerVerbosity.Basic, "VDMService", "Failed to register VDM Notification. Reason: " + e.Message); return(0U); } }