public async void Run(IBackgroundTaskInstance taskInstance) { deferral = taskInstance.GetDeferral(); taskInstance.Canceled += TaskInstance_Canceled; List <Task> setupTasks = new List <Task>(); setupTasks.Add(ComponentHandler.RegisterComponent(new SocketListener(8027))); setupTasks.Add(ComponentHandler.RegisterComponent(new SocketListener(8031, DataFormat.Json))); shield = await FEZUtilityShield.CreateAsync().ConfigureAwait(false); gripper = new GripperComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P3))); setupTasks.Add(ComponentHandler.RegisterComponent(gripper)); turntable = new TurnTableComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P0))); setupTasks.Add(ComponentHandler.RegisterComponent(turntable)); lowerLever = new LeverComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P1)), "LowerLever"); setupTasks.Add(ComponentHandler.RegisterComponent(lowerLever)); upperLever = new LeverComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P2)), "UpperLever"); setupTasks.Add(ComponentHandler.RegisterComponent(upperLever)); var videoDevices = await CameraComponent.GetAllVideoDevices().ConfigureAwait(false); if (videoDevices.Count > 0) { frontCamera = new CameraComponent("FrontCamera", new MediaCaptureInitializationSettings { StreamingCaptureMode = StreamingCaptureMode.Video, PhotoCaptureSource = PhotoCaptureSource.Auto, AudioDeviceId = string.Empty, VideoDeviceId = videoDevices[0].Id }); setupTasks.Add(ComponentHandler.RegisterComponent(frontCamera)); } await Task.WhenAll(setupTasks).ConfigureAwait(false); }