private async void ExecuteRunningToggle(object argument)
        {
            if (IsBusy)
            {
                RunButtonText = "Stop";

                Telemetry.TrackEvent("App.Start");
                CancellationToken = new CancellationTokenSource();

                if (LedListener == null)
                {
                    try
                    {
                        var gpio = Windows.Devices.Gpio.GpioController.GetDefault();
                        if (gpio != null)
                        {
                            Telemetry.TrackEvent("LED.Found");
                            await Log("Initialising LED listener...");

                            LedListener = new LEDLightListener();
                            LedListener.Subscribe(BuildMonitor, Settings);
                            LedListener.Start();
                        }
                        else
                        {
                            // We are running on a machine that does not support the ledlistener, so flag it as successfully started
                        }
                    }
                    catch (Exception ex)
                    {
                        Telemetry.TrackError(ex);
                        Debug.WriteLine("Could not initialise LED listener: " + ex.Message);
                    }
                }

                await Log("Starting build monitor...");

                BuildMonitor.Start(Settings, CancellationToken.Token);
            }
            else
            {
                RunButtonText = "Start";

                Telemetry.TrackEvent("App.StopClick");
                if (LedListener != null)
                {
                    LedListener.Dispose();
                    LedListener.Unsubscribe(BuildMonitor);
                    LedListener = null;
                }
                CancellationToken.Cancel();
            }
        }
Example #2
0
        private async void ExecuteRunningToggle(object argument)
        {
            if (IsBusy)
            {
                RunButtonText = "Stop";

                Telemetry.TrackEvent("App.Start");
                CancellationToken = new CancellationTokenSource();

                if (LedListener == null)
                {
                    try
                    {
                        var gpio = Windows.Devices.Gpio.GpioController.GetDefault();
                        if (gpio != null)
                        {
                            Telemetry.TrackEvent("LED.Found");
                            await Log("Initialising LED listener...");
                            LedListener = new LEDLightListener();
                            LedListener.Subscribe(BuildMonitor, Settings);
                            LedListener.Start();
                        }
                        else
                        {
                            // We are running on a machine that does not support the ledlistener, so flag it as successfully started
                        }
                    }
                    catch (Exception ex)
                    {
                        Telemetry.TrackError(ex);
                        Debug.WriteLine("Could not initialise LED listener: " + ex.Message);
                    }
                }

                await Log("Starting build monitor...");
                BuildMonitor.Start(Settings, CancellationToken.Token);
            }
            else
            {
                RunButtonText = "Start";

                Telemetry.TrackEvent("App.StopClick");
                if (LedListener != null)
                {
                    LedListener.Dispose();
                    LedListener.Unsubscribe(BuildMonitor);
                    LedListener = null;
                }
                CancellationToken.Cancel();
            }
        }