Question: I am trying to create a basic promise with a progress function like: 

```
asyncCall().then(function () {
                    that.output("complete");
                },
                null,
                function(v) {
                    that.output(v);
                }).done();

function asyncCall() {
        return new WinJS.Promise(function (complete, error, progress) {
            progress("some progress");
            setTimeout(function () {
                complete();
            }, 1000);
        });
    }

```

I would expect this to output 'progress' for 1 second and then display 'complete'; however, 'progress' is never outputted. Debugging the javascript, the progress function gets called on the promise object however it gets to this code (line 1447 of base.js) and listeners is undefined:

```
function progress(promise, value) {
        var listeners = promise._listeners;
        if (listeners) {

```

Any idea what I'm missing to handle the progress event?

Answer: 
It's actually working as designed, while not necessarily as expected. The `progress` is called for any current listeners. But, as your method is entirely synchronous, there are no listeners connected when the first call is made. Unlike other Promise functionality, this is a bit different, as other functions such as the complete and error can still be called.

You could see this if you wrapped your asyncCall code:

```
function asyncCall() {
    return new WinJS.Promise(function (complete, error, progress) {
        setImmediate(function() {
           progress('hello!');
           setTimeout(function() {
               complete();
           }, 1000);
        }, 0); 
    };

}

```
What's happening is that you're call to progress() is happening synchronously with the creation of the new WinJS.Promise. That is, the WinJS.Promise class gets instantiated, and as part of its initialization it calls your anonymous initializer with the complete, error, and progress dispatchers, as I call them.

These dispatchers each manage an array of handlers that are attached to them (the "listeners"), so that when you call them, like you're doing with progress() and complete(), they iterate through that array and call each handler in turn.

However, at this point in the execution, no handlers have been attached to anything because asyncCall has not yet returned, and in fact, new WinJS.Promise has not yet returned. So your call progress("some progress") happens just fine, but the dispatcher has no attached handlers so nothing happens.

Your completed handler gets called because setTimeout yields the UI thread, allowing your initializer to return, allowing the WinJS.Promise constructor to return, allowing asyncCall to return a new promise. It's only at that point that your call to the promise's then attaches your completed and progress handlers. So one second later, when the timeout comes back, the call to complete() invokes your handler.

In short, your progress handler is never called because your promise initializer is calling it synchronously with creation of the promise. Try doing something like this in your initializer: 

```
setTimeout(function () {
   progress("some progress");
}, 100);

```

This will also yield, getting you out of the promise creation, such that your progress handler will be attached. You could also do a setInterval to call progress every 100ms, making sure to cancel the interval when the 1s completion timeout happens. Then you'd see repeated calls to your progress handler.

Bottom line is that any synchronous call to complete, error, or progress inside the promise initializer will not touch your handlers passed to then, because then won't have been called.