private static int Fast(ConsoleCardPrinter consoleCardPrinter) { int numberOfHands = 0; bool isStillRunning = true; While(new ParallelOptions {MaxDegreeOfParallelism = 5}, () => { return isStillRunning; }, state => { var deck = new Deck(new GuidShuffler(), new ANormalDeck()); deck.Shuffle(); var hand = deck.TakeOneHand(); if (CheckIfHandHoldFourAces(hand)) { var cards = hand.Cards(); consoleCardPrinter.Print(cards); isStillRunning = false; } deck.Reset(); numberOfHands++; }); return numberOfHands; }
private static int Slow(ConsoleCardPrinter consoleCardPrinter) { bool isStillRunning = true; int numberOfHands = 0; var deck = new Deck(new GuidShuffler(), new ANormalDeck()); do { deck.Shuffle(); var hand = deck.TakeOneHand(); if (CheckIfHandHoldFourAces(hand)) { var cards = hand.Cards(); consoleCardPrinter.Print(cards); isStillRunning = false; } deck.Reset(); numberOfHands++; } while (isStillRunning); return numberOfHands; }