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 6214643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:54:51+00:00 2026-05-24T06:54:51+00:00

I am trying to log the user in automatically on the spash page before

  • 0

I am trying to log the user in automatically on the spash page before the application launces, however the below code dosent work. I put break points in and it seems loginDone is never called. Very similar code works fine when launched from a button. Is there something special about the Application_Launching method that means it cant download strings? Possibly not everything has been initialised so it wont work but then I would expect it to error.

private void Application_Launching(object sender, LaunchingEventArgs e)
    {
        done = false;

        IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
        appSettings.Remove("sid");
        if (appSettings.Contains("username") && appSettings.Contains("password")) {
            WebClient wc = new WebClient();
            wc.DownloadStringCompleted += loginDone;
            wc.DownloadStringAsync(InkBunnyUrls.Login(appSettings["username"].ToString(), appSettings["password"].ToString()));

            for (int i = 0; (i < 60 && !done); i++) {
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }
        }
    }

    private void loginDone(object sender, DownloadStringCompletedEventArgs e)
    {
        IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
        XDocument loginxml = XDocument.Parse(e.Result);
        var sid = (loginxml.Descendants("response").Elements("sid")).FirstOrDefault();
        if (sid == null || sid.Value.Length < 1) {
            appSettings.Add("sid", sid.Value);
        }

        done = true;

    }
  • 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-05-24T06:54:52+00:00Added an answer on May 24, 2026 at 6:54 am

    WebClient isn’t as asynchronous as one might expect – it does various things on the UI thread, including the DownloadStringCompleted handling. So whatever it needs to do will be waiting to get hold of the UI thread – which you’ve blocked for a minute with your for loop.

    It’s generally a really bad idea to hold up the UI thread like this. I would launch with a splash screen showing “Downloading file…” leaving the UI thread nicely idle and able to process events like the web request completing – and then when the file has finished downloading, you can move onto your “real” first screen.

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

Sidebar

Related Questions

I'm trying to log in to a website and save an HTML page automatically
I am trying to automatically log the user to a diff website when the
I spent a day trying to make Ent Lib Logging work and log anything
I have the following code (attempting to log a user in programatically): List<GrantedAuthority> authorities
I am trying to log forcefully when a user has been inactive and or
I'm trying create a log specifically for logging user account activity. I created this
I'm trying to log in a user as part of a form submit, but
I am trying to log in a user to facebook using an offline token
I'm querying a very large activity log in a MySQL database, trying to figure
I'm slightly puzzled with what should log out a user. At the moment I

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.