////https://stackoverflow.com/questions/24158814/ping-sendasync-always-successful-even-if-client-is-not-pingable-in-cmd //private async Task PingHostAsync(uint ipAddress, int TimeOut, byte[] buffer, PingOptions options) //{ // Interlocked.Increment(ref _WorkingTaskCount); // try // { // Ping ping = new Ping(); // PingReply reply = await ping.SendPingAsync(IPTools.UInt322IPAddressStr(ipAddress), TimeOut, buffer, options); // if (!wasStopped) { // try // { // if (reply.Status == IPStatus.Success) // { // uint address = IPTools.IPAddress2UInt32(reply.Address); // IPInfo ipInfo = new IPInfo(address, reply.RoundtripTime); // ipInfo.HostDetailsBeforeChanged += TSub_BeforeChanged; // ipInfo.HostDetailsAfterChanged += TSub_AfterChanged; // ipInfo.setHostDetailsAsync(); // Buffer.AddLine(ipInfo); // } // } // catch (Exception ex) // { // Debug.WriteLine(ex.Message + "\r" + ex.StackTrace); // } // } // //Interlocked.Decrement(ref _WorkingTaskCount); // lock (Locker) // { // _WorkingTaskCount--; // _progress++; // } // } // catch (Exception ex) // { // Debug.WriteLine(ex.Message + "\r" + ex.StackTrace); // } // if (!wasStopped) // { // try // { // lock (Locker) // { // Tasks.Remove(ipAddress); // } // } // catch (Exception ex) // { // Debug.WriteLine(ex.Message + "\r" + ex.StackTrace); // } // } //} #endregion private void PingHost(uint ipAddress, int TimeOut, byte[] buffer, PingOptions options) { try { Ping ping = new Ping(); string ip = IPTools.UInt322IPAddressStr(ipAddress); PingReply reply = ping.Send(ip, TimeOut, buffer, options); if (!WasStopped) { try { if (reply.Status == IPStatus.Success) { uint address = IPTools.IPAddress2UInt32(reply.Address); IPInfo ipInfo = new IPInfo(address, reply.RoundtripTime); ipInfo.HostDetailsBeforeChanged += TSub_BeforeChanged; ipInfo.HostDetailsAfterChanged += TSub_AfterChanged; ipInfo.SetHostDetailsAsync(); Buffer.AddLine(ipInfo); } } catch (Exception ex) { _logger.Error(ex); } } Interlocked.Increment(ref _progress); _logger.Trace(string.Concat(TaskId, ": ", ip, ": ", reply.Status)); } catch (Exception ex) { _logger.Error(ex); } }
/// <summary> /// /// </summary> public void Render() { // Draw walls Buffer.Clear(); foreach (Wall wall in Walls) { Buffer.AddLine(wall.From, wall.To, Color.Red); } int count = Buffer.Update(); Display.DrawBatch(Buffer, 0, count); // Draw lights foreach (Light light in Lights) { light.Render(Buffer); } }