Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9237747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:36:11+00:00 2026-06-18T07:36:11+00:00

Now I think I understand why this happening so I guess my question is

  • 0

Now I think I understand why this happening so I guess my question is how can I modify the code to act how I want.

First the code.

private void btnLiveSignin_Click(object sender, RoutedEventArgs e)
{
    var LoggedIn = Login();

    busy.Visibility = System.Windows.Visibility.Visible;  // Display the please wait message

    if (LoggedIn.Result)
    {
        // Do something 
    }
}

public async Task<bool> Login()
{
    try
    {
        var e = await lac.InitializeAsync(Scopes);

        if (e.Status == LiveConnectSessionStatus.Connected)
        {
            client = new LiveConnectClient(e.Session);

            // do some stuff now that we are connected

            return true;
        }
        else
        {
            // not connected so do something

            return false;
        }
    }
    catch (Exception ex)
    {
        return false;
    }
}

Basically when the user clicks a button it will log them in to their windows live account and while that is happening a message appears asking the user to please wait.

As you can guess the UI locks so the message never appears. How can I change it so the UI doesn’t lock?

I done this with windows phone 7.5 before using events as the sdk didn’t use async, and that worked perfectly fine. Would this require a mixture of asyncing and events?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:36:13+00:00Added an answer on June 18, 2026 at 7:36 am

    What you’re missing from your handler is async and await.

    Because you marked your Login method as async and made it return a task, you’ve made it awaitable, which makes it possible to re-write your event-handler as:

    private async void btnLiveSignin_Click(object sender, RoutedEventArgs e)
    {
        var loginTask = this.Login();
    
        busy.Visibility = System.Windows.Visibility.Visible; 
    
        await loginTask;
    
        if(loginTask.Result)
        {
           // Do something 
        }
    }
    

    Marking the event-handler as async indicates to the caller that it will complete asynchronously. What await does is “signal” that you want to wait for the task to complete before continuing. Together this means that the event-handler can return an “incomplete” result back to the dispatcher (the UI thread) which will run in the background without disrupting the UI.

    As a rule, once you start using async and await in your code, you should try using them “all the way down”.

    async and await are a bit devious in how the compiler turns them into “real” code, so don’t be surprised if you need to read more around the topic to understand them fully.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear all,Now i have this question in my java program,I think it should be
Think I have an integer array like this: a[0]=60; a[1]=321; a[2]=5; now I want
I think my question is pretty basic, but I'm writing this code in OpenCV
I understand this question has been asked before, but I couldn't think of a
Well, i've walking around this for a couples of days now... I think is
right now this code works for tomorrow and next month - weekend use to
First of all, I want to make myself clear that I do understand that
I understand that this is an insanely broad topic, but can anyone give me
UPDATE2: I think I got it now: <?php /* * @name Lawler's algorithm PHP
Now I am using Adobe Cirrus in my Flex app, but I think that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.