diff --git a/src/windows8/BarcodeScannerProxy.js b/src/windows8/BarcodeScannerProxy.js index 9384214a3..e0a1b59f7 100644 --- a/src/windows8/BarcodeScannerProxy.js +++ b/src/windows8/BarcodeScannerProxy.js @@ -20,6 +20,7 @@ module.exports = { var capturePreview = null, captureCancelButton = null, + captureCanceled = false, capture = null, captureSettings = null, reader = null, @@ -74,8 +75,10 @@ module.exports = { reader = new WinRTBarcodeReader.Reader(capture, bitmapWidth, bitmapHeight); var readOp = reader.readCode(); readOp.done(function (result) { - destroyPreview(); - success({ text: result.text, format: result.barcodeFormat, cancelled: false }); + if (!captureCanceled) { + destroyPreview(); + success({ text: result.text, format: result.barcodeFormat, cancelled: false }); + } }); } @@ -105,6 +108,7 @@ module.exports = { * See https://github.com/phonegap-build/BarcodeScanner#using-the-plugin */ function cancelPreview() { + captureCanceled = true; destroyPreview(); success({ text: null, format: null, cancelled: true }); } diff --git a/src/windows8/lib/WinRTBarcodeReader.winmd b/src/windows8/lib/WinRTBarcodeReader.winmd index 91c415c5a..d57ed806c 100644 Binary files a/src/windows8/lib/WinRTBarcodeReader.winmd and b/src/windows8/lib/WinRTBarcodeReader.winmd differ diff --git a/src/windows8/lib/WinRTBarcodeReader/WinRTBarcodeReader/Reader.cs b/src/windows8/lib/WinRTBarcodeReader/WinRTBarcodeReader/Reader.cs index bc4cec0f4..3a52d755a 100644 --- a/src/windows8/lib/WinRTBarcodeReader/WinRTBarcodeReader/Reader.cs +++ b/src/windows8/lib/WinRTBarcodeReader/WinRTBarcodeReader/Reader.cs @@ -108,16 +108,18 @@ public void Stop() private async Task Read() { Result result = null; - while (!this.barcodeFound) + try { - try + while (!this.barcodeFound) { + result = await this.GetCameraImage(this.cancelSearch.Token); + } - catch (OperationCanceledException) - { - result = null; - } + } + catch (OperationCanceledException) + { + result = null; } return result;