using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Text;
namespace Demo2
{
class Program
{
static void Main(string[] args)
{
const int taskcount = 10;
//事件数组,记录线程执行状态
var mevents = new ManualResetEventSlim[taskcount];
//等待数组,接收事件发出的信号
var waithandles = new WaitHandle[taskcount];
//执行具体任务的类
var calcs = new Calculator[taskcount];
//任务工厂
TaskFactory tf = new TaskFactory();
for (int i = 0; i data = (Tuple)obj;
Console.Write("Task {0} starts calculation\r\n", Task.CurrentId);
Thread.Sleep(new Random().Next(3000));
TaskID = Task.CurrentId;
Console.Write("Task {0} is ready\r\n", Task.CurrentId);
mevent.Set();
}
}
}