using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace ProcessBarForm
{
public partial class Form1 : Form
{
System.Windows.Forms.Timer TM = new System.Windows.Forms.Timer();
AutoResetEvent AutoRest = new AutoResetEvent(false);
public Form1()
{
InitializeComponent();
ProgressBar.CheckForIllegalCrossThreadCalls = false;
TM.Interval = 1;
TM.Tick+=new EventHandler(TM_Tick);
}
void TM_Tick(object sender, EventArgs e)
{
AutoRest.Set();
}
private void Form1_Load(object sender, EventArgs e)
{
progressBar1.Value = 0;
progressBar1.Maximum =1000;
}
private void button1_Click(object sender, EventArgs e)
{
TM.Start();
Thread ThreadProcess = new Thread(AA);
ThreadProcess.IsBackground = true;
ThreadProcess.Start();
}
void AA()
{
for (int i = 0; i < 1000; i++)
{
progressBar1.Value = i;
AutoRest.WaitOne();
}
}
private void button2_Click(object sender, EventArgs e)
{
TM.Stop();
}
private void button3_Click(object sender, EventArgs e)
{
TM.Start();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace ProcessBarForm
{
public partial class Form1 : Form
{
System.Windows.Forms.Timer TM = new System.Windows.Forms.Timer();
AutoResetEvent AutoRest = new AutoResetEvent(false);
public Form1()
{
InitializeComponent();
ProgressBar.CheckForIllegalCrossThreadCalls = false;
TM.Interval = 1;
TM.Tick+=new EventHandler(TM_Tick);
}
void TM_Tick(object sender, EventArgs e)
{
AutoRest.Set();
}
private void Form1_Load(object sender, EventArgs e)
{
progressBar1.Value = 0;
progressBar1.Maximum =1000;
}
private void button1_Click(object sender, EventArgs e)
{
TM.Start();
Thread ThreadProcess = new Thread(AA);
ThreadProcess.IsBackground = true;
ThreadProcess.Start();
}
void AA()
{
for (int i = 0; i < 1000; i++)
{
progressBar1.Value = i;
AutoRest.WaitOne();
}
}
private void button2_Click(object sender, EventArgs e)
{
TM.Stop();
}
private void button3_Click(object sender, EventArgs e)
{
TM.Start();
}
}
}