IEventActivity接口的原型如下
1
IComparable QueueName
2
{
3
get;
4
}
5
void Subscribe(ActivityExecutionContext parentContext, IActivityEventListener<QueueEventArgs> parentEventHandler);
6![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
void Unsubscribe(ActivityExecutionContext parentContext, IActivityEventListener<QueueEventArgs> parentEventHandler);
其中QueueName表示消息队列的名字。将IEventActivity活动放入在ListenActivity中时,ListenActivity活动启动时首先调用Subscribe方法,表示它开始订阅事件,通常应该在这儿做初始化工作。当ListenActivity活动从消息队列中收到一条消息时,它将调用Unsubscrible方法,表示已经收到消息,在此方法实现时应当从消息队列中读取消息,并做一些资源清理工作。![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
在ListenActivity中的IEventActivity活动的执行过程为
Subscribe();
Unsubscribe();
Execute();
不在ListenActivity中的活动的执行过程为
Execute();
Waitting for queue event.