I have a function that performs a long task. I would like to create a function that is able to notify the caller of the progress. Ultimately I want to update the UI with the current progress.

Something like this:

```
function myLongMethod(progressCallback)
{
    for(var i = 0 ... )
    {
        progressCallback(i) ;
    }

}

```

This works but updates on UI are not smooth. Is there a better way? I would prefer something with a jquery Deferred object using deferred.notify(). Any ideas?