private void button2_Click(object sender, EventArgs e)
{
string btnName = button2.Text;
if (btnName == "启动")
{
isCancel = false;
button2.Enabled = false;
var t = new Task(() => TaskBoot("TaskBoot"));
t.Start();
button2.Text = "停止";
button2.Enabled = true;
}
else
{
isCancel = true;
isComple = true;
button2.Enabled = true;
button2.Text = "启动";
}
}
static void TaskBoot(string name)
{
int taskCount = 5;
taskList = new Task[taskCount];
int taskCurrent;
int rwCount = 20; //要执行总任务数
int rwNum = 0;
C# Task多线程任务传递参数,指定数量停止源代码
最新推荐文章于 2023-06-01 17:06:18 发布