CSharp · Console
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using System.Text.RegularExpressions;
public class Program
{
private static List<IPStatus> _results;
public static async Task MyMethodAsync(IPAddress ip)
{
await Task.Delay(500);
Console.WriteLine("processing");
}
public static async Task Asd()
{
var options = new ExecutionDataflowBlockOptions{MaxDegreeOfParallelism = 2};
var block = new ActionBlock<IPAddress>(ip => MyMethodAsync(ip), options);
var list = new List<IPAddress>{IPAddress.Loopback, IPAddress.Loopback, IPAddress.Loopback, IPAddress.Loopback, IPAddress.Loopback, IPAddress.Loopback, IPAddress.Loopback, IPAddress.Loopback, IPAddress.Loopback};
foreach (var ip in list)
{
block.Post(ip);
}
block.Complete();
await block.Completion;
}
public static void Main()
{
Dictionary<DateTime, List<string>> Sample = new Dictionary<DateTime, List<string>>();
Sample.Add( DateTime.Parse("5/8/2018 11:18:00 AM"), new List<string>());
Sample.Add( DateTime.Parse("5/8/2018 11:17:46 AM"), new List<string>());
Sample.Add( DateTime.Parse("2/27/2010 1:06:49.123456 PM"), new List<string>());
Sample.Add( DateTime.Parse("5/8/2018 11:18:08 AM"), new List<string>());
DateTime date = DateTime.Parse("2/27/2010 1:06:49 PM");
foreach (KeyValuePair<DateTime, List<string>> k in Sample)
{
if (date.Ticks/10000000 == k.Key.Ticks/10000000)
{
Console.WriteLine("Yes");
}
else {
Console.WriteLine("No");
}
}
}
}