question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UWP Unable to update UI after scanning

See original GitHub issue

After scanning a QR Code, I perform a long running task, and update the UI to notify the user that the task is running. This does not work after performing a scan. Below is the code I am using to try and update the UI.

public sealed partial class MainPage : Page
{

    MobileBarcodeScanner scanner;

    public MainPage()
    {
        this.InitializeComponent();
        scanner = new MobileBarcodeScanner(Dispatcher);
    }

    public void NotifyUser(bool runningLongTask)
    {
        // Update Some UI stuff here
    }

    private async void StartScan(object sender, RoutedEventArgs e)
    {
        await scanner.Scan().ContinueWith(async t =>
        {
            if (t.Result != null && !string.IsNullOrEmpty(t.Result.Text))
            {
                // Update UI Components.  Does not work
                NotifyUser(true);

                // Simulate a long running task
                await Task.Delay(10000);

                // Update UI Components.  Does not work again.
                NotifyUser(false);

            }
        });
    }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Redthcommented, May 12, 2016

Added this to the sample and README in 4b45f9079366fc62ff6aeec12fbbe02db597b53b

1reaction
chromos33commented, May 12, 2016

Ok my very similar problem was fixed. Anyone having this problem might look into the solution in #320 . adding NavigationCacheMode=“Enabled” to the Page (in Xamarin PCL add this to the UWP Project MainPage.xaml not in any xaml files in the PCL folder as it does not exist in Xamarin)

If this solves it, it might be a good idea to include that into the Readme. And thanks again to Strifex for this solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UWP update UI from Task
So I would like to update the UI during the scan. So here are the questions: At this moment I have several tasks...
Read more >
Unable to update UI controls on UWP app after scanning with ...
I recently created a cross platform project in Visual Studio 2015 for Xamarin Forms. The purpose is to have a very simple barcode...
Read more >
Launch the Windows Settings app - UWP applications
Learn how to launch the Windows Settings app from your app using the ms-settings URI scheme.
Read more >
Version adaptive apps - UWP applications
Learn how to take advantage of new APIs while maintaining compatibility with previous versions.
Read more >
Dell Command Update 4.7 pulled? : r/SCCM
I hope they fixed problem in 4.6.0 that I wasn't able to install as system and configure, still have a ticket open on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found