MotivaTED/Views/HealthView.xaml.cs
/// <summary>
/// Handles streaming of HR Rate from the MS Band
/// </summary>
Handles streaming of HR Rate from the MS Band
Handles streaming of HR Rate from the MS Band
private async void HRStreaming_Handler()
        {
            if (model.Main.BandClient != null)
            {
                using (new DisposableAction(() => model.StreamingBusy = true, () => model.StreamingBusy = false))
                {
                    if (HRStreaming.Visibility == Visibility.Collapsed)
                    {
                        model.Main.BandClient.SensorManager.HeartRate.ReadingChanged += HeartRate_ReadingChanged;
                        await model.Main.BandClient.SensorManager.HeartRate.StartReadingsAsync(new CancellationToken());
                        HRStreaming.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        model.Main.BandClient.SensorManager.HeartRate.ReadingChanged -= HeartRate_ReadingChanged;
                        await model.Main.BandClient.SensorManager.HeartRate.StopReadingsAsync(new CancellationToken());
                        HRStreaming.Visibility = Visibility.Collapsed;
                    }
                }
            }
        }
private async void HRStreaming_Handler ( ) { if ( model . Main . BandClient != null ) { using ( new DisposableAction ( ( ) => model . StreamingBusy = true , ( ) => model . StreamingBusy = false ) ) { if ( HRStreaming . Visibility == Visibility . Collapsed ) { model . Main . BandClient . SensorManager . HeartRate . ReadingChanged += HeartRate_ReadingChanged ; await model . Main . BandClient . SensorManager . HeartRate . StartReadingsAsync ( new CancellationToken ( ) ) ; HRStreaming . Visibility = Visibility . Visible ; } else { model . Main . BandClient . SensorManager . HeartRate . ReadingChanged -= HeartRate_ReadingChanged ; await model . Main . BandClient . SensorManager . HeartRate . StopReadingsAsync ( new CancellationToken ( ) ) ; HRStreaming . Visibility = Visibility . Collapsed ; } } } }
Handles streaming of HR Rate from the MS Band
Handles streaming of HR Rate from the MS Band
//subscribe to HR //unsubscribe to HR