using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading;
using
System.Windows.Forms;
namespace
作业队列
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
button1_Click(
object
sender, EventArgs e)
{
Thread thread =
new
Thread(() =>
{
zong(1);
});
thread.IsBackground =
true
;
thread.Start();
}
private
void
zong(
int
i)
{
testc action = NewMethod1;
action += NewMethod2;
action += NewMethod3;
while
(
true
)
{
action();
}
}
private
delegate
void
testc();
private
void
NewMethod1()
{
try
{
for
(
int
i = 0; i <= 100; i++)
{
this
.BeginInvoke((EventHandler)(
delegate
{ progressBar1.Value = i; }));
System.Threading.Thread.Sleep(100);
double
ii = i * 1.0 / 100 * 100;
this
.BeginInvoke((EventHandler)(
delegate
{ label1.Text = ii.ToString() +
"%"
; }));
if
(i == 100)
{
this
.BeginInvoke((EventHandler)(
delegate
{ progressBar1.Value = 0; }));
this
.BeginInvoke((EventHandler)(
delegate
{ label1.Text =
"0%"
; }));
}
}
}
catch
{ }
}
private
void
NewMethod2()
{
try
{
for
(
int
i = 0; i <= 100; i++)
{
this
.BeginInvoke((EventHandler)(
delegate
{ progressBar2.Value = i; }));
System.Threading.Thread.Sleep(100);
double
ii = i * 1.0 / 100 * 100;
this
.BeginInvoke((EventHandler)(
delegate
{ label2.Text = ii.ToString() +
"%"
; }));
}
}
catch
{ }
}
private
void
NewMethod3()
{
try
{
for
(
int
i = 0; i <= 100; i++)
{
this
.BeginInvoke((EventHandler)(
delegate
{ progressBar3.Value = i; }));
System.Threading.Thread.Sleep(100);
double
ii = i * 1.0 / 100 * 100;
this
.BeginInvoke((EventHandler)(
delegate
{ label3.Text = ii.ToString() +
"%"
; }));
if
(i == 100)
{
this
.BeginInvoke((EventHandler)(
delegate
{ progressBar3.Value = 0; }));
this
.BeginInvoke((EventHandler)(
delegate
{ label3.Text =
"0%"
; }));
}
}
}
catch
{ }
}
}
}