Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition issue when subscribing to ProviderStateChanged #124

Closed
pekspro opened this issue Jul 18, 2021 · 0 comments · Fixed by #125
Closed

Race condition issue when subscribing to ProviderStateChanged #124

pekspro opened this issue Jul 18, 2021 · 0 comments · Fixed by #125
Labels
bug 🐛 Something isn't working Completed 🔥
Milestone

Comments

@pekspro
Copy link
Contributor

pekspro commented Jul 18, 2021

Describe the bug

There is a race condition issue when subscribing to ProviderManager.Instance.ProviderStateChanged. Currently this only works if you do this before ProviderManager.Instance.GlobalProvider is setup.

Steps to Reproduce

It is easy to see this in the UwpMsalProviderSample project. Change the constructor of LoginButton to this:

    public LoginButton()
    {
        InitializeComponent();

        _ = Task.Run(async () =>
        {
            await Task.Delay(2000);

            _ = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
           {
               ProviderManager.Instance.ProviderStateChanged += (s, e) => UpdateState();
               UpdateState();
           });
        });
    }

Now when the application is executed the text on the sign in button will not be updated.

Expected behavior

It should not matter when you subscribe to ProviderManager.Instance.ProviderStateChanged.

Additional context

I will create an PR for this.

@pekspro pekspro added the bug 🐛 Something isn't working label Jul 18, 2021
@ghost ghost added the Completed 🔥 label Jul 19, 2021
@shweaver-MSFT shweaver-MSFT added this to the 7.1.0 milestone Aug 6, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 Something isn't working Completed 🔥
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants