JQuery Progress Bar sleeping at the beginning
<p>Could you give me some advice why a progress bar is seeping at the beginning and what's going on in that moment?
WebForm1.aspx page</p>

<pre><code>&lt;%@ Page Language="vb" AutoEventWireup="false" Async="true" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;

    &lt;link type="text/css" href="css/ui-lightness/jquery-ui-1.8.14.custom.css" rel="Stylesheet" /&gt;   
&lt;script type="text/javascript" src="js/jquery-1.5.1.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"&gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;
    &lt;div id="progressbar"&gt;&lt;/div&gt;
    &lt;div id="result"&gt;&lt;/div&gt;&lt;br /&gt;

        &lt;asp:Button ID="btnShowProgress" runat="server" Text="Start" /&gt;&lt;br /&gt;

    Percentage:&lt;asp:Label ID="percentage" runat="server"&gt;&lt;/asp:Label&gt;


        &lt;script type="text/javascript"&gt;
            $(function () {

                // Progressbar
                $("#progressbar").progressbar({ value: 0 });
                setTimeout(updateProgress, 10);

                // start updating
                $(document).ready(function () {
                    // TODO: revert the line below in your actual code
                    $("#progressbar").progressbar();
                    setTimeout(updateProgress, 10);
                });

                function updateProgress() {
                    $.ajax({
                        type: "POST",
                        url: "WebForm1.aspx/GetData",
                        data: "{}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        async: true,
                        success: function (msg) {
                            $("#progressbar").progressbar("option", "value", msg.d);
                            $("#percentage").text(msg.d);
                            if (msg.d &lt; 100) {
                                setTimeout(updateProgress, 10);
                            }
                        }
                    });
                }
                // end updating

                //hover states on the static widgets
                $('#dialog_link, ul#icons li').hover(
                    function () { $(this).addClass('ui-state-hover'); },
                    function () { $(this).removeClass('ui-state-hover'); }
                );
            });
        &lt;/script&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>and the WebForm1.aspx.vb page</p>

<pre><code>Imports System.Threading
Imports System.Web.Services

Public Class WebForm1
    Inherits System.Web.UI.Page

    Shared Bw As ComponentModel.BackgroundWorker
    Public Shared Percent As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnShowProgress_Click(sender As Object, e As EventArgs) Handles btnShowProgress.Click
        'For i As Integer = 0 To 100
        '    hfValueINeedToKnow.Value = i.ToString()
        '    Threading.Thread.Sleep(500)
        'Next



        Bw = New ComponentModel.BackgroundWorker()
        Bw.WorkerReportsProgress = True
        Bw.WorkerSupportsCancellation = True

        AddHandler Bw.DoWork, AddressOf bw_DoWork
        AddHandler Bw.ProgressChanged, AddressOf bw_ProgressChanged
        AddHandler Bw.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted

        Bw.RunWorkerAsync("Hello world")

    End Sub


    Shared Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)


        For i As Integer = 0 To 100 Step 1

            If (Bw.CancellationPending) Then
                e.Cancel = True
                Return
            End If
            Bw.ReportProgress(i)
            Thread.Sleep(500)
        Next
        e.Result = "100%"
    End Sub

    Public Sub bw_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs)

        percentage.Text = "Complete: " + e.Result      ' from DoWork
    End Sub

    Public Sub bw_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs)

        Percent = e.ProgressPercentage
    End Sub

    &lt;WebMethod(BufferResponse:=False)&gt;
    Public Shared Function GetData() As Integer

        Return Percent
    End Function



End Class
</code></pre>
