private async void ScanImageAsync(byte[] pixelsArray)
        {
            await _semScan.WaitAsync();

            try
            {
                if (_processScan)
                {
                    var result = BarCodeManager.ScanBitmap(pixelsArray, (int)_width, (int)_height);
                    if (result != null)
                    {
                        OnBarCodeFoundAsync(result.Text);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                // Wasn't able to find a barcode
            }
            finally
            {
                _semScan.Release();
            }
        }
 private async void OnErrorAsync(Exception e)
 {
     await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
         CoreDispatcherPriority.Normal, () =>
     {
         BarCodeManager.OnError(e);
         this.Frame.GoBack();
     });
 }
        private async void OnBarCodeFoundAsync(string barcode)
        {
            _processScan = false;

            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal, () =>
            {
                if (BarCodeManager.OnBarCodeFound != null)
                {
                    Debug.WriteLine(barcode);
                    BarCodeManager.OnBarCodeFound(barcode);
                }

                this.Frame.GoBack();
            });
        }