C# Task多线程任务传递参数,指定数量停止源代码
作者:互联网
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;
标签:Task,源代码,int,Enabled,TaskBoot,button2,多线程,true 来源: https://blog.csdn.net/yixin8/article/details/113831979