guanqixu.SimpleNetStatusPolling 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package guanqixu.SimpleNetStatusPolling --version 1.0.0                
NuGet\Install-Package guanqixu.SimpleNetStatusPolling -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="guanqixu.SimpleNetStatusPolling" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add guanqixu.SimpleNetStatusPolling --version 1.0.0                
#r "nuget: guanqixu.SimpleNetStatusPolling, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install guanqixu.SimpleNetStatusPolling as a Cake Addin
#addin nuget:?package=guanqixu.SimpleNetStatusPolling&version=1.0.0

// Install guanqixu.SimpleNetStatusPolling as a Cake Tool
#tool nuget:?package=guanqixu.SimpleNetStatusPolling&version=1.0.0                

简单说明

该包简单实现网络轮询的功能,检查指定 ip 地址和端口的网络服务状态是否可建立连接;

代码例子

using SimpleNetStatusPolling;
using System;
using System.Collections.Generic;
using System.Net;

namespace SimpleNetStatusPollingDemo
{
    class Program
    {
        /// <summary>
        /// 主程序
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            List<IPEndPoint> ipes = new List<IPEndPoint>();
            for (int i = 1; i < 200; i++)
            {
                var ipe = new IPEndPoint(IPAddress.Parse($"14.215.177.{i}"), 80);
                ipes.Add(ipe);
            }

            NetStatusPollingService service = new NetStatusPollingService(ipes);
            service.PollingProgressing += Service_PollingProgressing;
            service.PollingFinished += Service_PollingFinished;

            service.Start();
            string input;
            do
            {
                input = Console.ReadLine();
                if (input == "s")
                {
                    service.Start(2000, 10);
                }
                else if (input == "e")
                {
                    service.Stop();
                }
                else if (string.IsNullOrWhiteSpace(input))
                {
                    service.Stop();
                    break;
                }

            } while (input != "");
        }

        /// <summary>
        /// 轮询完成,返回所有结果
        /// </summary>
        /// <param name="obj"></param>
        private static void Service_PollingFinished(Dictionary<IPEndPoint, bool> obj)
        {
            Console.WriteLine("Finished! " + obj.Count);
            foreach (var item in obj)
            {
                Console.WriteLine($"{item.Key}, {item.Value}");
            }
        }

        /// <summary>
        /// 单次轮询,返回每次的结果
        /// </summary>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        private static void Service_PollingProgressing(IPEndPoint arg1, bool arg2)
        {
            Console.WriteLine($"Processing! {arg1}, {arg2}");
        }
    }
}


Product Compatible and additional computed target framework versions.
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.4 559 3/16/2020
1.2.3 606 1/19/2020
1.2.2 578 1/19/2020
1.2.1 473 1/16/2020
1.0.1 533 1/13/2020
1.0.0 533 1/11/2020

第一个版本,网络轮询服务