private void ScanPreviewBuffer() { if (!IsAnalyzing) { return; } if (_photoCamera == null) { return; } if (!_initialized) { return; } // Don't scan too frequently // Check the minimum time between frames // as well as the min time between continuous scans var msSinceLastPreview = (DateTime.UtcNow - _lastAnalysis).TotalMilliseconds; if ((DateTime.UtcNow - _lastAnalysis).TotalMilliseconds < Options.DelayBetweenAnalyzingFrames || (_wasScanned && msSinceLastPreview < Options.DelayBetweenContinuousScans)) { return; } _wasScanned = false; _lastAnalysis = DateTime.UtcNow; try { _photoCamera.GetPreviewBufferY(_luminance.PreviewBufferY); var binarizer = new ZXing.Common.HybridBinarizer(_luminance); var binBitmap = new BinaryBitmap(binarizer); var result = _reader.decode(binBitmap); if (result != null) { _wasScanned = true; OnDecodingCompleted(result); } } catch (Exception) { // If decoding fails it will throw a ReaderException // and we're not interested in doing anything with it } }