/// <summary> /// Keeps the IIS application pool alive. /// </summary> private void KeepIisAlive() { try { if (!IisHelper.IsHostedByIis) { return; } if (_ping != null && _ping.Execute()) { return; } IEnumerable <Uri> uris = IisHelper.GetUris(); foreach (Uri uri in uris) { Ping ping = new Ping(uri); if (ping.Execute()) { _ping = ping; break; } } } catch (Exception ex) { Log.Error(ex); } }
public string Ping(byte[] message) { ValidateNotDisposed(); using var connection = new RedisConnection(_connectionSettings); var command = new Ping(connection.GetStream(), message); return(command.Execute()); }
private static void RunPing() { try { _ping1 = ExternalLib.Request.Ping(new string[] { "2.16.840.1.114416.0.57513008" }); RequestStatusChangedItem item = _ping1.Execute(TimeSpan.FromSeconds(30)); if (null == item) { _ping1.Cancel(); } } catch (Exception ex) { Console.WriteLine("RunPing: " + ex.Message); } }
public void Ping_Execute_Returns_Pong() { //------------Setup for test-------------------------- var now = DateTime.Now; var ping = new Ping { Now = () => now }; var expected = "Pong @ " + now.ToString("yyyy-MM-dd hh:mm:ss.fff"); //------------Execute Test--------------------------- var result = ping.Execute(It.IsAny <Dictionary <string, StringBuilder> >(), It.IsAny <IWorkspace>()); var ser = new Dev2JsonSerializer(); var msg = ser.Deserialize <ExecuteMessage>(result); //------------Assert Results------------------------- Assert.AreEqual(expected, msg.Message.ToString()); }