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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:27:11+00:00 2026-06-15T23:27:11+00:00

My understanding of the WinJS.Application.start() function is that it allows WinJS to queue up

  • 0

My understanding of the WinJS.Application.start() function is that it allows WinJS to queue up certain normal page initialization events to give you a chance to set up other data first in your default.js file. By calling the start() function at the end of default.js, WinJS then fires off all the queued events for you (such as the activated event).

I’m trying to understand where everything fits in the life cycle, so I’m not clear why the first of the following examples works but the second doesn’t. All I’m doing is updating the page title, which doesn’t work as expected when I call app.start() after a 5-second delay:

First, here’s default.html:

<html>
<head>
    <script references...>
</head>
<body>
    <h1 id="pageTitle">Page of coolness...</h1>
</body>
</html>

And here’s the first default.js example (which works as expected):

(function () {

    var app = WinJS.Application;

    app.onactivated = function () {
            document.getElementById("pageTitle").innerText = "Rock it!";
    };

    // This code *does* fire the onactivated event:
    //   The page displays "Rock it!" in the page title
    app.start();

})();

Here’s the second default.js example (which doesn’t work as expected):

(function () {

    var app = WinJS.Application;

    app.onactivated = function () {
            document.getElementById("pageTitle").innerText = "Rock it!";
    };

    // This code *doesn't* fire the onactivated event:
    //   It initially displays "Page of coolness..." in the page title.
    //   After 5 seconds, it adds "Gettin' there...Almost made it..." 
    //   to the the page title, but "Rock it!" never gets displayed
    WinJS.Promise.timeout(5000).then(function () {
        document.getElementById("pageTitle").innerText += "Gettin' there...";
        app.start();
        document.getElementById("pageTitle").innerText += "Almost made it...";
    });
})();

Why does calling app.start() after the 5-second delay cause the activated event not to fire?

  • 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-15T23:27:13+00:00Added an answer on June 15, 2026 at 11:27 pm

    The documentation for the start function is a little misleading.

    When you call start, WinJS.Application begins to queue and dispatch events, including those which are emitted by Windows.UI.WebUI.WebUIApplication. One of these events is activated, which is what leads to your handler function being called.

    The important point is that the queuing doesn’t begin until you call start. Any events that are emitted by WebUIApplication before the queuing begins are lost forever.

    This is the situation you have created by delaying your call to start: the activated event is sent by WebUIApplication before the WinJS.Application queue has been set up. The activated event is never received by WinJS.Application and so your handler function is never invoked.

    I know you are just trying to figure out the life cycle, but there isn’t a reason to delay your call to the start function in real life. The only way to get the effect you are trying to create in your code is to place the Promise inside the onactivated handler function, like this:

    (function () {
    
        var app = WinJS.Application;
    
        app.onactivated = function () {
            document.getElementById("pageTitle").innerText += "Gettin' there...";
    
            WinJS.Promise.timeout(5000).then(function () {
                document.getElementById("pageTitle").innerText = "Rock it!";
            });
            document.getElementById("pageTitle").innerText += "Almost made it...";
    
        };
    
        app.start();
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My understanding of the Integer.TryParse() function was that it tried to parse an integer
My understanding is that C++ allows static const members to be defined inside a
My understanding is that when you kill a C++ application through Task Manager in
My understanding is that the queue based approach to concurrency can be implemented without
My understanding is that there are certain advantages to putting two related sites under
My understanding of the Sleep function is that it follows at least semantics i.e.
Understanding that I should probably just dig into the source to come up with
My understanding is that when using && as an mathematical operation in Java, if
My understanding is that OpenSSL is deprecated in OSX 10.7 in favor of Common
My understanding is that threads in theory are executed in parallel. JVM decides; when

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.