O'Reilly logo

C# 7 and .NET Core Cookbook by Dirk Strauss

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. In the Demo class, add a method called CheckClientMachinesOnline(), which takes as parameters a List<string> collection of IP addresses and an integer that specifies the minimum number of machines required to be online. Add a second method called MachineReturnedPing(), which will receive an IP address to ping. For our purpose, we will just return false to mimic a dead machine (the ping to the IP address timed out):
        public class Recipes         {           public void CheckClientMachinesOnline(List<string> ipAddresses,             int minimumLive)           {                   }              private bool MachineReturnedPing(string ip)             {                         return false;           }          }
  1. Inside the CheckClientMachinesOnline() method, add the Parallel.ForEach loop and create the ParallelOptions variable that will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required