本文整理汇总了C#中Host.BringUpIfDown方法的典型用法代码示例。如果您正苦于以下问题:C# Host.BringUpIfDown方法的具体用法?C# Host.BringUpIfDown怎么用?C# Host.BringUpIfDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host.BringUpIfDown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BringUpIfDown_Should_Allow_Multiple_Concurrent_Calls
public void BringUpIfDown_Should_Allow_Multiple_Concurrent_Calls()
{
var policy = new CountReconnectionPolicy(100);
var host = new Host(Address, policy);
var counter = 0;
host.Up += _ => Interlocked.Increment(ref counter);
host.SetDown();
TestHelper.ParallelInvoke(() =>
{
host.BringUpIfDown();
}, 100);
//Should fire event only once
Assert.AreEqual(1, counter);
}
示例2: BringUpIfDown_Resets_Attempt_Reconnection_Flag
public void BringUpIfDown_Resets_Attempt_Reconnection_Flag()
{
var policy = new CountReconnectionPolicy(long.MaxValue);
var host = new Host(Address, policy);
host.SetDown();
Assert.True(host.SetAttemptingReconnection());
//Next times it should be false
Assert.False(host.SetAttemptingReconnection());
Assert.False(host.SetAttemptingReconnection());
Assert.False(host.SetAttemptingReconnection());
host.BringUpIfDown();
//next time should be allowed
Assert.True(host.SetAttemptingReconnection());
}