Full Site Version
using System;
using System.Linq;
using System.Threading.Tasks;
public class Program
{
public static void Main()
var numbers = Enumerable.Range(0, 10);
Parallel.ForEach(numbers, i =>
VoteMachine.RegisterVote();
});
Console.WriteLine(VoteMachine.TotalVotes);
}
public class VoteMachine
private static int _totalVotes = 0;
static VoteMachine()
public static void RegisterVote()
_totalVotes += 1;
Console.WriteLine("Registered Vote #" + _totalVotes);
public static int TotalVotes
get
return _totalVotes;