示例#1
0
        protected override void StopListening()
        {
            // disconnect the contact event for non-contact probes. this probe has already been marked as non-running, so
            // there's no risk of a race condition in which the contact state changes to worn and the change event attempts
            // to restart this probe after it has been stopped (we check Running during the change event).
            if (!(this is MicrosoftBandContactProbe))
            {
                MicrosoftBandContactProbe contactProbe = Protocol.Probes.Single(probe => probe is MicrosoftBandContactProbe) as MicrosoftBandContactProbe;
                contactProbe.ContactStateChanged -= ContactStateChanged;
            }

            StopReadings();

            // only cancel the static health test if none of the band probes should be running.
            if (BandProbesThatShouldBeRunning.Count == 0)
            {
                CancelHealthTest();
            }

            // disconnect the client if no band probes are actually running.
            if (BandProbesThatAreRunning.Count == 0 && (BandClient?.IsConnected ?? false))
            {
                try
                {
                    SensusServiceHelper.Get().Logger.Log("All Band probes have stopped. Disconnecting client.", LoggingLevel.Normal, GetType());
                    BandClient.DisconnectAsync().Wait();
                    BandClient = null;
                }
                catch (Exception ex)
                {
                    SensusServiceHelper.Get().Logger.Log("Failed to disconnect client:  " + ex.Message, LoggingLevel.Normal, GetType());
                }
            }
        }
        protected override void StopListening()
        {
            StopReadings();

            // only cancel the static health test if none of the band probes should be running.
            if (BandProbesThatShouldBeRunning.Count == 0)
            {
                CancelHealthTest();
            }

            // disconnect the client if no band probes are actually running.
            if (BandProbesThatAreRunning.Count == 0 && (BandClient?.IsConnected ?? false))
            {
                try
                {
                    SensusServiceHelper.Get().Logger.Log("All Band probes have stopped. Disconnecting client.", LoggingLevel.Normal, GetType());
                    BandClient.DisconnectAsync().Wait();
                    BandClient = null;
                }
                catch (Exception ex)
                {
                    SensusServiceHelper.Get().Logger.Log("Failed to disconnect client:  " + ex.Message, LoggingLevel.Normal, GetType());
                }
            }
        }
        public override async Task Destroy()
        {
            await base.Destroy();

            await BandClient.TileManager.StopEventListenersAsync();

            await BandClient.DisconnectAsync();
        }
示例#4
0
        public override async Task Destroy()
        {
            await base.Destroy();

            await BandClient.DisconnectAsync();
        }