예제 #1
0
파일: ScannerInit.cs 프로젝트: dansool/xx
        public async Task <bool> ReleaseScannerAsync(bool exit)
        {
            try
            {
                if (claimedScanner != null)
                {
                    claimedScanner.DataReceived           -= ClaimedScanner_DataReceivedAsync;
                    claimedScanner.ReleaseDeviceRequested -= OnClaimedScannerReleaseDeviceRequested;
                    claimedScanner.IsDecodeDataEnabled     = false;
                    await claimedScanner.DisableAsync();

                    claimedScanner.Dispose();
                }
                scanner = null;
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
예제 #2
0
        protected override async void OnNavigatedFrom(NavigationEventArgs e)
        {
            using (ExitLocker)
            {
                await Task.Run(() =>
                {
                    ExitLocker.WaitOne();
                });
            }

            if (Capture != null)
            {
                using (Capture)
                {
                    await Capture.StopPreviewAsync();

                    PreviewControl.Source = null;
                }
            }

            if (ClaimedScanner != null)
            {
                using (ClaimedScanner)
                {
                    await ClaimedScanner.StopSoftwareTriggerAsync();

                    await ClaimedScanner.DisableAsync();

                    ClaimedScanner.DataReceived -= ClaimedScanner_DataReceived;
                }
            }
            BarcodeHistory.Clear();
            BarcodeHistory = null;
            ExitLocker     = null;
            Capture        = null;
            ClaimedScanner = null;
        }