async Task ProcessRawAsync(IOutputPort cameraPort, CancellationToken cancellationToken = default) { await using (cancellationToken.Register(() => cameraPort.Trigger.SetResult(true))) { cameraPort.DisablePort(); cameraPort.Start(); StartCapture(cameraPort); await cameraPort.Trigger.Task.ConfigureAwait(false); StopCapture(cameraPort); _camera.CleanPortPools(); } }
/// <summary> /// Acts as an isolated processor specifically used when capturing raw frames from the camera component. /// </summary> /// <param name="cameraPort">The camera component port (still or video).</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The awaitable task.</returns> private async Task ProcessRawAsync(IOutputPort cameraPort, CancellationToken cancellationToken = default(CancellationToken)) { using (cancellationToken.Register(() => { // this callback will be executed when token is cancelled cameraPort.Trigger.SetResult(true); })) { cameraPort.DisablePort(); cameraPort.Start(); this.StartCapture(cameraPort); await cameraPort.Trigger.Task.ConfigureAwait(false); this.StopCapture(cameraPort); this.Camera.CleanPortPools(); } }