Aidy,
Thanks for the response.
Here's the ASPX code:
<ajax:ScriptManager id="ScriptManager1" runat="server"
EnablePartialRendering="true" EnablePageMethods="true"/>
<ajax:Timer ID="ajaxTimer" runat="server" Interval="1"
OnTick="ajaxTimer_OnTick" />
<ajax:UpdatePanel ID="upLoadTools" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<div class="progress">
<app
rogressBar id="ImportProgressBar" height="20em" runat="server" />
</div>
<asp:Button ID="_btnLoadTools" runat="server" CssClass="formbutton"
Text="Load Tools" OnClick="_btnLoadTools_Click" ToolTip="Load Tools" />
</ContentTemplate>
<Triggers>
<ajax:AsyncPostBackTrigger ControlID="ajaxTimer" EventName="Tick" />
</Triggers>
</ajax:UpdatePanel>
And here's the code that starts the thread:
protected void _btnLoadTools_Click(object sender, EventArgs e) {
this.ajaxTimer.Enabled = true;
Thread t = new Thread((ThreadStart)delegate { CreateTools(); });
t.IsBackground = true;
t.Start();
}
And here's the code in the Tick event of the Timer:
protected void ajaxTimer_OnTick(object sender, EventArgs e) {
this.ImportProgressBar.Percentage = Percentage;
this.upLoadTools.Update();
}
The OnTick event dies after the Thread is started. However, I did figure
this out.
I put a conditional Sleep on the Thread that gives up the processor to the
ASPX worker process. The problem is that the Thread was basically hogging
the ASPX worker process and wouldn't give up any time to the client. With
some strategically placed Thread.Sleeps, I was able to get the progress bar
to update correctly.
What I didn't realize is that this isn't the same kind of multi-threading
enviornment that I'm familiar with. If you start a Thread in the ASPX worker
process' space, it basically takes over the whole process space. If you
don't put it to sleep, it'll rarely give up the time to the client.
Thanks for the help and I hope this helps others figure out this problem.
Amrit