private void DeRegisterForNotifications() { try { // De-Register for IMbnInterfaceManagerEvents if (m_InterfaceManagerEventsSink != null) { m_InterfaceManagerEventsSink.Dispose(); m_InterfaceManagerEventsSink = null; } // De-Register for IMbnPinManagerEvents if (m_PinManagerEventsSink != null) { m_PinManagerEventsSink.Dispose(); m_PinManagerEventsSink = null; } // De-Register for IMbnPinManagerEvents if (m_PinEventsSink != null) { m_PinEventsSink.Dispose(); m_PinEventsSink = null; } // De-Register for IMbnConnectionEvents if (m_ConnectionEventsSink != null) { m_ConnectionEventsSink.Dispose(); m_ConnectionEventsSink = null; } // De-Register for IMbnDeviceServicesEvents if (m_DeviceServicesEventsSink != null) { m_DeviceServicesEventsSink.Dispose(); m_DeviceServicesEventsSink = null; } } catch (Exception e) { rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage); } }
// Un-register notifications private void DeRegisterForNotifications() { try { // De-Register for IMbnInterfaceManagerEvents if (m_InterfaceManagerEventsSink != null) { m_InterfaceManagerEventsSink.Dispose(); m_InterfaceManagerEventsSink = null; } // De-Register for IMbnPinManagerEvents if (m_PinManagerEventsSink != null) { m_PinManagerEventsSink.Dispose(); m_PinManagerEventsSink = null; } // De-Register for IMbnPinManagerEvents if (m_PinEventsSink != null) { m_PinEventsSink.Dispose(); m_PinEventsSink = null; } // De-Register for IMbnConnectionEvents if (m_ConnectionEventsSink != null) { m_ConnectionEventsSink.Dispose(); m_ConnectionEventsSink = null; } // De-Register for IMbnDeviceServicesEvents if (m_DeviceServicesEventsSink != null) { m_DeviceServicesEventsSink.Dispose(); m_DeviceServicesEventsSink = null; } } catch (Exception e) { rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage); } }
// Register for notifications private void RegisterForNotifications() { try { if (m_MbnInterface == null) { // Get the interface m_MbnInterface = GetFirstInterface(); } if (m_MbnConnection == null) { m_MbnConnection = m_MbnInterface.GetConnection(); } if (m_MbnDeviceServicesContext == null) { m_MbnDeviceServicesContext = m_MbnDeviceServicesManager.GetDeviceServicesContext(m_MbnInterface.InterfaceID); } // Register for IMbnInterfaceManagerEvents if (m_InterfaceManagerEventsSink == null) { m_OnInterfaceArrivalEventDelegate = new OnInterfaceArrivalHandler(ProcessOnInterfaceArrival); m_OnInterfaceRemovalEventDelegate = new OnInterfaceRemovalHandler(ProcessOnInterfaceRemoval); m_InterfaceManagerEventsSink = new InterfaceManagerEventsSink(m_OnInterfaceArrivalEventDelegate, m_OnInterfaceRemovalEventDelegate, GetMbnInterfaceManagerEventsConnectionPoint()); } // Register for IMbnPinManagerEvents if (m_PinManagerEventsSink == null) { m_OnGetPinStateCompleteEventDelegate = new OnGetPinStateCompleteHandler(ProcessOnGetPinStateCompleteHandlerEvt); m_PinManagerEventsSink = new PinManagerEventsSink(m_OnGetPinStateCompleteEventDelegate, GetMbnPinManagerEventsConnectionPoint()); } // Register for IMbnPinEvents if (m_PinEventsSink == null) { m_OnEnterCompleteEventDelegate = new OnEnterCompleteHandler(ProcessOnEnterComplete); m_PinEventsSink = new PinEventsSink(m_OnEnterCompleteEventDelegate, GetMbnPinEventsConnectionPoint()); } // Register for IMbnConnectionEvents if (m_ConnectionEventsSink == null) { m_OnConnectCompleteEventDelegate = new OnConnectCompleteHandler(ProcessOnConnectComplete); m_OnDisconnectCompleteEventDelegate = new OnDisconnectCompleteHandler(ProcessOnDisconnectComplete); m_ConnectionEventsSink = new ConnectionEventsSink(m_OnConnectCompleteEventDelegate, m_OnDisconnectCompleteEventDelegate, GetMbnConnectionEventsConnectionPoint()); } // Register for IMbnDeviceServicesEvents if (m_DeviceServicesEventsSink == null) { m_OnOpenCommandSessionCompleteEventDelegate = new OnOpenCommandSessionCompleteHandler(ProcessOnOpenCommandSessionComplete); m_OnQueryCommandCompleteEventDelegate = new OnQueryCommandCompleteHandler(ProcessOnQueryCommandComplete); m_OnCloseCommandSessionEventDelegate = new OnCloseCommandSessionCompleteHandler(ProcessOnCloseCommandSessionComplete); m_DeviceServicesEventsSink = new DeviceServicesEventsSink( m_OnOpenCommandSessionCompleteEventDelegate, m_OnQueryCommandCompleteEventDelegate, m_OnCloseCommandSessionEventDelegate, GetMbnDeviceServicesEventsConnectionPoint()); } } catch (Exception e) { rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage); } }
private void RegisterForNotifications() { try { if (m_MbnInterface == null) { m_MbnInterface = GetFirstInterface(); } if (m_MbnConnection == null) { m_MbnConnection = m_MbnInterface.GetConnection(); } if (m_MbnDeviceServicesContext == null) { m_MbnDeviceServicesContext = m_MbnDeviceServicesManager.GetDeviceServicesContext(m_MbnInterface.InterfaceID); } // Register for IMbnInterfaceManagerEvents if (m_InterfaceManagerEventsSink == null) { m_OnInterfaceArrivalEventDelegate = new OnInterfaceArrivalHandler(ProcessOnInterfaceArrival); m_OnInterfaceRemovalEventDelegate = new OnInterfaceRemovalHandler(ProcessOnInterfaceRemoval); m_InterfaceManagerEventsSink = new InterfaceManagerEventsSink(m_OnInterfaceArrivalEventDelegate, m_OnInterfaceRemovalEventDelegate, GetMbnInterfaceManagerEventsConnectionPoint()); } // Register for IMbnPinManagerEvents if (m_PinManagerEventsSink == null) { m_OnGetPinStateCompleteEventDelegate = new OnGetPinStateCompleteHandler(ProcessOnGetPinStateCompleteHandlerEvt); m_PinManagerEventsSink = new PinManagerEventsSink(m_OnGetPinStateCompleteEventDelegate, GetMbnPinManagerEventsConnectionPoint()); } // Register for IMbnPinEvents if (m_PinEventsSink == null) { m_OnEnterCompleteEventDelegate = new OnEnterCompleteHandler(ProcessOnEnterComplete); m_PinEventsSink = new PinEventsSink(m_OnEnterCompleteEventDelegate, GetMbnPinEventsConnectionPoint()); } // Register for IMbnConnectionEvents if (m_ConnectionEventsSink == null) { m_OnConnectCompleteEventDelegate = new OnConnectCompleteHandler(ProcessOnConnectComplete); m_OnDisconnectCompleteEventDelegate = new OnDisconnectCompleteHandler(ProcessOnDisconnectComplete); m_ConnectionEventsSink = new ConnectionEventsSink(m_OnConnectCompleteEventDelegate, m_OnDisconnectCompleteEventDelegate, GetMbnConnectionEventsConnectionPoint()); } // Register for IMbnDeviceServicesEvents if (m_DeviceServicesEventsSink == null) { m_OnOpenCommandSessionCompleteEventDelegate = new OnOpenCommandSessionCompleteHandler(ProcessOnOpenCommandSessionComplete); m_OnQueryCommandCompleteEventDelegate = new OnQueryCommandCompleteHandler(ProcessOnQueryCommandComplete); m_OnCloseCommandSessionEventDelegate = new OnCloseCommandSessionCompleteHandler(ProcessOnCloseCommandSessionComplete); m_DeviceServicesEventsSink = new DeviceServicesEventsSink( m_OnOpenCommandSessionCompleteEventDelegate, m_OnQueryCommandCompleteEventDelegate, m_OnCloseCommandSessionEventDelegate, GetMbnDeviceServicesEventsConnectionPoint()); } } catch (Exception e) { rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage); } }