using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Syslab.Sample.Ex06
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Person> persons = new List<Person>(new Person[] 
                {
                    new Person() {  Name = "José",Age = 54},
                    new Person() {  Name = "Maria",Age = 65},
                    new Person() {  Name = "Aparecida",Age = 46}
                });

            Parallel.ForEach<Person>(persons, p => Loop(p));
        }

        static void Loop(Person p)
        {
            Console.WriteLine(p); 
        }
    }

    class Person
    {
        public string Name
        {
            get;
            set;
        }

        public int Age
        {
            get;
            set;
        }

        public override string ToString()
        {
            return string.Format("Name: {0}, Age: {1}", this.Name, this.Age);
        }
    }
}
