本文整理汇总了C#中EventPublisher.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# EventPublisher.SendMessage方法的具体用法?C# EventPublisher.SendMessage怎么用?C# EventPublisher.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventPublisher
的用法示例。
在下文中一共展示了EventPublisher.SendMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFileFollowerwithEventAggregator
public void TestFileFollowerwithEventAggregator()
{
var broker = new EventAggregator(new ChannelManager(), new ContextFactory());
var publisher = new EventPublisher(broker);
var filefollower = new FileFollower(publisher);
Guid identifier = Guid.Empty;
var longrunningcontext = new PoolFiber();
longrunningcontext.Start();
//register with longrunning context.
broker.AddListener<StartFollowingFileMessage>(longrunningcontext, filefollower.Handle);
//register with normal context.
broker.AddListener<StopFollowingFileMessage>(filefollower.Handle);
var reset = new AutoResetEvent(false);
broker.AddListener<FollowerStartedMessage>(message =>
{
Console.WriteLine("Follower Started" + message.Identifier);
identifier = message.Identifier;
broker.SendMessage(new StopFollowingFileMessage(identifier));
});
broker.AddListener<FollowerStoppedMessage>(message =>
{
if (message.Identifier == identifier)
{
Console.WriteLine("Follower stopped" + message.Identifier);
reset.Set();
}
});
publisher.SendMessage(new StartFollowingFileMessage(@"ExampleFiles/ExampleLogFiles/LotroLog.txt"));
Assert.IsTrue(reset.WaitOne(5000, false));
}