日期:2014-05-18 浏览次数:20990 次
using System.Threading;
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("This is the main thread");
}
private Thread trd;
private void ThreadTask()
{
int stp;
int newval;
Random rnd=new Random();
while(true)
{
stp=this.progressBar1.Step*rnd.Next(-1,2);
newval = this.progressBar1.Value + stp;
if (newval > this.progressBar1.Maximum)
newval = this.progressBar1.Maximum;
else if (newval < this.progressBar1.Minimum)
newval = this.progressBar1.Minimum;
this.progressBar1.Value = newval;
Thread.Sleep(100);
}
}