本文整理汇总了C#中Bus.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Bus.Close方法的具体用法?C# Bus.Close怎么用?C# Bus.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bus
的用法示例。
在下文中一共展示了Bus.Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Status_Connected_And_Then_Closed
public void Status_Connected_And_Then_Closed()
{
var _busConfigurationBuilder = new BusConfigurationBuilder();
_busConfigurationBuilder.ConnectionUris.Add(TestingConfiguration.LocalConnectionUri);
var _busConfirguration = _busConfigurationBuilder.Build();
var _SUT = new Bus(_busConfirguration);
_SUT.Connect();
Assert.AreEqual(BusStatus.Connected, _SUT.Status);
_SUT.Close();
Assert.AreEqual(BusStatus.Closed, _SUT.Status);
}
示例2: ManyValues
public void ManyValues()
{
Channel<int> channel1 = new Channel<int>();
Channel<double> channel2 = new Channel<double>();
for (int i = 1; i <= 1000; i++)
{
channel1.Send(i);
channel2.Send(-i*0.5);
}
Thread.Sleep(100);
List<int> result1 = new List<int>();
List<double> result2 = new List<double>();
var bus = new Bus(new IChannel[] {channel1, channel2},
new ChannelOptions[] {
new ChannelOptions(false),
new ChannelOptions(false)});
for (int i = 1; i <= 1000; i++)
{
object[] objects = bus.Receive();
Expect(objects.Length, EqualTo(2));
result1.Add((int) objects[0]);
result2.Add((double) objects[1]);
}
bus.Close();
for (int i = 1; i <= 1000; i++)
Expect(result1.Contains(i), String.Format("Missing number: {0} ({1} received)", i, result1.Count));
for (int i = 1; i <= 1000; i++)
Expect(result2.Contains(-i*0.5), String.Format("Missing number: {0} ({1} received)", i, result1.Count));
}
示例3: TwoChannels
public void TwoChannels()
{
Channel<int> channel1 = new Channel<int>();
Channel<double> channel2 = new Channel<double>();
channel1.Send(2);
channel2.Send(3.5);
double result = 0;
Bus bus = new Bus(new IChannel[] {channel1, channel2},
new ChannelOptions[] {
new ChannelOptions(false),
new ChannelOptions(false)});;
object[] objects = bus.Receive();
bus.Close();
Expect(objects.Length, EqualTo(2));
result = (int) objects[0] + (double) objects[1];
Expect(result, EqualTo(2 + 3.5));
}
示例4: OneChannel
public void OneChannel()
{
Channel<int> channel = new Channel<int>();
channel.Send(5);
int result = 0;
Bus bus = new Bus(new IChannel[] {channel},
new ChannelOptions[] {new ChannelOptions(false)});
object[] objects = bus.Receive();
bus.Close();
Expect(objects.Length, EqualTo(1));
result = (int) objects[0];
Expect(result, EqualTo(5));
}