|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using hmlib.Web.UI.Controls;
namespace WebTest.ProgressBarTest
{
public partial class ProgressBar_OnCompleteTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static object getProgress(string progressId)
{
return Progress.GetResponse(progressId);
}
protected void btnStart_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
Progress progress = ProgressBar1.Progress;
Thread thread = new Thread(() => Start(progress));
thread.Start();
btnStart.Enabled = false;
//ProgressBar1.Completed = false;
}
private void Start(Progress progress)
{
double max = 100;
progress.AddMessageLine("Started");
for (int i = 0; i < max; i++)
{
progress.SetProgress(i / max);
progress.AddMessageLine((i / max) * 100);
Thread.Sleep(50);
}
progress.AddMessageLine("Finished");
progress.SetProgress(1);
}
protected void ProgressBar1_Complete(object sender, EventArgs e)
{
btnStart.Enabled = true;
Label1.Text = DateTime.Now.ToString();
}
}
}
|
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.