using log4net; namespace Aucma.Core.Scanner { /// /// 扫码器初始化 /// public class ScannerService : IScannerService { private static readonly log4net.ILog log = LogManager.GetLogger(typeof(ScannerService)); public async Task StartScannerAsync() { try { MvCodeHelper.DeviceListAcq();//获取设备 MvCodeHelper.OpenDevice();//打开设备 MvCodeHelper.StartGrab();//获取数据 } catch (Exception ex) { log.Error(ex.Message); MvCodeHelper.CloseDevice(); await StartScannerAsync(); } } } }