|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using hmlib.Web.UI.Controls;
namespace WebTest.ProgressBarTest
{
public partial class ucStartOnServerSide : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
this.ProgressBar1.ProgressId = "TestProgress";
}
protected void btnStart_Click(object sender, EventArgs e)
{
btnStart.Enabled = false;
rbSpeed.Enabled = false;
int interval = int.Parse(rbSpeed.SelectedValue);
Thread thread = new Thread(() => this.StartProgress(ProgressBar1.Progress, interval));
thread.Start();
}
private void StartProgress(Progress progress, int interval)
{
int rounds = int.Parse(rbRounds.SelectedValue);
for (int i = 0; i < rounds; i++)
{
progress.SetProgress(0);
progress.AddMessageLine("Round " + (i + 1) + " started");
for (int j = 0; j < 100; j++)
{
//interval = Math.Max(10, interval - 1);
double value = .98 * j / 100d;
progress.SetProgress(value);
//progress.AddMessageLine(value.ToString());
Thread.Sleep(interval);
}
}
progress.AddMessageLine("Finished");
progress.SetProgress(1);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.