Event topics how to

Topics: CAB & Smart Client Software Factory
Jan 6, 2006 at 7:55 AM
originally posted by: SUBATBLOOMINGTON


How do i publish events / handle events dynamically using Event topics using event broker

any sample will help
Jan 8, 2006 at 7:52 PM
originally posted by: jburtch

I coded up this single WorkItem and it seems to work. Of course since you need to pass in a parent WorkItem into the AddPublication and AddSubscription methods, you need a reference to the WorkItem in the objects involved.

public class MainWorkItem : WorkItem {
public event EventHandler GenericEvent;

public void AddPublisher() {
EventTopic topic = new EventTopic();
topic.AddPublication(this, "GenericEvent", this, PublicationScope.Global);
EventTopics.Add(topic, "topic://my/dynamic/event");

public void AddSubscriber() {
EventTopic topic = EventTopics.Get("topic://my/dynamic/event");
topic.AddSubscription(this, "GenericHandler", this, ThreadOption.Publisher);

public void GenericHandler(object sender, EventArgs e) {

protected override void OnRunStarted() {


if (GenericEvent != null) {
GenericEvent(this, EventArgs.Empty);


Hope this quick sample helps.

Justin Burtch