예제 #1
0
    static void Main(string[] args)
    {
      var start = DateTime.Now;
      var stopWatch = new CustomStopwatch();
      stopWatch.Start();

      var tasks = new Task<int>[args.Length];
      var cmds = new string[tasks.Length];
      times = new TimeSpan[tasks.Length];

      for (var i = 0; i < args.Length; i++)
      {
        cmds[i] = args[i];
      }

      Console.WriteLine("We start the analyses");
      for (var i = 0; i < tasks.Length; i++)
      {
        var clousotArgs = new List<string>();
        clousotArgs.Add(cmds[i]);

        Console.WriteLine("call: " + i);
        var local = i; // without it we get the wrong parameter!!!!!!!!
        tasks[i] = new Task<int>(() => CallClousotEXE(local, clousotArgs.ToArray()));
        tasks[i].Start();
      }

      Console.WriteLine("We wait");
      Task.WaitAll(tasks);

      for(var i = 0; i < tasks.Length; i++)
      {
        Console.WriteLine("Time for {0} was : {1}", i, times[i]);
      }

      Console.WriteLine("we are done (in {0})! Press a key", stopWatch.Elapsed);
      Console.ReadKey();

    }