【问题标题】:ACR loading and ZXing handle resultACR 加载和 ZXing 处理结果
【发布时间】:2021-05-28 05:36:04
【问题描述】:

在一个非常简单的Xamarin android APP 中,我使用ZXing 扫描条形码,然后处理结果。处理结果需要几秒钟的时间,在我想显示ACR showLoading 期间,当扫描仪/相机关闭时,活动指示器几乎立即隐藏。

如何在处理结果时保持显示加载打开?

清理代码:

    async void onAddByScan(object sender, EventArgs e)
    {
        var options = new ZXing.Mobile.MobileBarcodeScanningOptions();
        var scanner = new MobileBarcodeScanner();
        ZXing.Result result = await scanner.Scan(options);
        using (UserDialogs.Instance.Loading())
        {
            await HandleResultAsync(result);
        }
    }

    async Task HandleResultAsync(ZXing.Result result)
    {
        //do something with the results
    }

【问题讨论】:

    标签: c# android xamarin zxing acr


    【解决方案1】:

    您可以在 Xamarin.Essentials: MainThread 类中使用 InvokeOnMainThreadAsync 方法。这种方法的想法不仅是在 UI/主线程上执行代码,而且还要等待它的代码。这样您就可以同时拥有异步/等待逻辑和主线程执行。

    你可以参考类似的案例https://stackoverflow.com/a/67483594/10768653

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-28
      • 2013-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-14
      • 1970-01-01
      • 2015-03-30
      相关资源
      最近更新 更多