public void OnImageAvailable(ImageReader reader)
            {
                if (_renderer.CancellationToken.IsCancellationRequested)
                {
                    return;
                }
                // get the byte array data from the first plane
                // of the image. This is sufficient for a JPEG
                // image
                Image image = reader.AcquireLatestImage();

                if (image != null)
                {
                    Image.Plane[] planes = image.GetPlanes();
                    ByteBuffer    buffer = planes[0].Buffer;
                    byte[]        bytes  = new byte[buffer.Capacity()];
                    buffer.Get(bytes);
                    // close the image so we can handle another image later
                    image.Close();
                    (_renderer.Element as LabelReader)?.ProcessPhoto(bytes);
                    // keeps capturing images until the annotations have
                    // been processed into ssid and password sucessfully
                    _renderer.CurrentContext.RunOnUiThread(async() => {
                        try {
                            await Task.Delay(LabelReaderConstants.ImageCaptureDelayMilliseconds, _renderer.CancellationToken);
                        } catch (TaskCanceledException) {
                            return;
                        }
                        _renderer.CaptureImage();
                    });
                }
            }
            public override void OnConfigured(CameraCaptureSession session)
            {
                // set a repeating request for a live preview of the camera
                _renderer.Session = session;
                CaptureRequest request = _renderer.Builder.Build();

                _renderer.Request = request;
                session.SetRepeatingRequest(request, _renderer.CaptureListener, null);
                // wait a bit before we start capturing the label (while the user
                // finds it and aligns it)
                _renderer.CurrentContext.RunOnUiThread(async() => {
                    try {
                        await Task.Delay(LabelReaderConstants.ImageCaptureBeginDelayMilliseconds, _renderer.CancellationToken);
                    } catch (TaskCanceledException) {
                        return;
                    }
                    _renderer.CaptureImage();
                });
            }