本文整理汇总了C#中ServiceClient.SayHiKey方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient.SayHiKey方法的具体用法?C# ServiceClient.SayHiKey怎么用?C# ServiceClient.SayHiKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.SayHiKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendKeepAliveMessage
private void SendKeepAliveMessage()
{
ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);
try
{
if (client.ClientCredentials != null)
{
client.ClientCredentials.Windows.ClientCredential.UserName = "admin";
client.ClientCredentials.Windows.ClientCredential.Password = "Green2o11";
}
if (client.SayHiKey(new HardwareKey().Key) != "Hi there")
{
Console.WriteLine("Server_Down");
}
else if (!this._checkedForNewMessages)
{
this._checkedForNewMessages = true;
}
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client.Abort();
}
catch (Exception exception3)
{
Console.WriteLine("Server Down" + exception3.Message + exception3.StackTrace);
}
}
示例2: StartKeepAliveThread
private void StartKeepAliveThread()
{
System.Timers.Timer timer = new Timer();
timer.Interval = (10000);
timer.Elapsed += delegate
{
ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);
try
{
if (client.ClientCredentials != null)
{
client.ClientCredentials.Windows.ClientCredential.UserName = "admin";
client.ClientCredentials.Windows.ClientCredential.Password = "Green2o11";
}
if (client.SayHiKey(new HardwareKey().Key) != "Hi there")
{
Console.WriteLine("Server_Down");
}
else if (!_checkedForNewMessages)
{
// this.GetMedia(null);
_checkedForNewMessages = true;
}
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client.Abort();
}
catch (Exception exception3)
{
Console.WriteLine("Server Down" + exception3.Message + exception3.StackTrace);
}
};
timer.Start();
}