本文整理汇总了C#中ServerConnection.Ping方法的典型用法代码示例。如果您正苦于以下问题:C# ServerConnection.Ping方法的具体用法?C# ServerConnection.Ping怎么用?C# ServerConnection.Ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServerConnection
的用法示例。
在下文中一共展示了ServerConnection.Ping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitialiseOpensTheWcfHost
public void InitialiseOpensTheWcfHost()
{
var channel = new Wcf();
var address = "net.tcp://localhost/client";
channel.Endpoints.Add(new NetTcp { Address = address });
var opened = false;
try
{
opened = channel.Initialise(null);
Assert.IsTrue(opened);
var connection = new ServerConnection(address, new NetTcpBinding());
var canPing = connection.Ping();
Assert.IsTrue(canPing);
}
finally
{
if (opened)
{
channel.CleanUp();
}
}
}
示例2: RunPingCommand
private static void RunPingCommand(ServerConnection connection)
{
WriteToConsole(ConsoleColor.DarkGray, "Sending ping...");
var stopwatch = new Stopwatch();
stopwatch.Start();
var result = connection.Ping();
stopwatch.Stop();
if (result)
{
WriteToConsole(ConsoleColor.DarkGray, "...ping received in {0}ms", stopwatch.ElapsedMilliseconds);
}
else
{
WriteToConsole(ConsoleColor.Red, "...ping failed!", stopwatch.ElapsedMilliseconds);
}
}
示例3: PingReturnsFalseOnFailure
public void PingReturnsFalseOnFailure()
{
var connection = new ServerConnection("net.tcp://nowhere");
var result = connection.Ping();
Assert.IsFalse(result);
}