UWP App Crash while after execution completed in UI thread RRS feed

  • Question

  • App is crashing in Windows 10 (UWP) app.

    I am using ZXing.Net.Mobile in UWP app and Invoking scanner object inside UI thread.

    Below code :

    private async Task<ZXing.Result> ScanBarcode()
    ZXing.Result result = null;
    var taskCompletionSource = new TaskCompletionSource<ZXing.Result>();
    await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
    async () =>
    var scanner = new MobileBarcodeScanner();
    var scannerOption = new MobileBarcodeScanningOptions { TryHarder = true, AutoRotate = false };
    scanner.TopText = "Focus the barcode or QR code in this frame. Wait until it is automatically scanned.";
    ////this.Log(LogLevel.Info, null, "Barcode scanner object created.");

                                  scanner.UseCustomOverlay = false;
                                  // Use front camera for Desktops/Tablets
                                  if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop")
                                      scannerOption.UseFrontCameraIfAvailable = true;
                                  result = await scanner.Scan(scannerOption);
            result = await taskCompletionSource.Task;
            return result;

    But this method i am calling from non ui thread.
    Once the execution is finished and passing value in UI that time i am getting crash.
    As per my understanding, once i invoking scanner object in UI thread and after reading data the UI thread is still alive because of that other part of view is not alive.

    Can you please suggest that how i will detached Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher

    and return back to my current view.

    My app is using webview control and called is invoking from html ui control.

    Crash Log Info --

    {"Exception from HRESULT: 0x80020101"}

    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
    at Intelatrac.Mobile.RTComponent.UWP.NavigatorRT.<>c__DisplayClass11_0.<<Navigator_OnVMPropertyChanged>b__0>d.MoveNext()

    Please suggest on this.


    Saturday, May 6, 2017 2:59 AM

All replies

  • Hi shishir,

    This is the forum to discuss questions and feedback for Windows 10 client, better to post your question to the forum for UWP:


    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, May 8, 2017 7:36 AM