Problem with Publication and Subscription

Topics: CAB & Smart Client Software Factory
Mar 1, 2006 at 4:38 PM
originally posted by: princealadin

I am working with Two Modules and in each module I have one Event Subscription to the same Event Publication on the third module. However, when the published event occurs, two subcription events occur at the same time. But I only want one of them occurs. How can I do that? How to determine exactly which one is the expected subcription event based on a certain condition?

For example: Two textboxes subscribe to the event button click in order to display the button label on the textboxes. If the label is A then only textbox A event will occur. If the label is B then only textbox B event will occur.

Could anyone help me on this problem?
Mar 1, 2006 at 4:49 PM
originally posted by: RolandLi

You can made your own EventArg which has an property to identify your "certain condition" .
The handlers check the EventArg first, if not the condition for it, then the handler just do nothing.
Mar 1, 2006 at 4:49 PM
originally posted by: matiaswoloski

You cannot avoid both events to happen (you can only choose if an event is broadcasted Globallly or inside the WorkItem).
What you can do is react different inside the event handler by reading the EventArgs.

EVentSubscription...
public void HandlerOnModule2( object sender, EventArgs<string> e ) {
if ( e.Data = "Foo" ) {
...
}
}

EVentSubscription...
public void HandlerOnModule3( object sender, EventArgs<string> e ) {
if ( e.Data = "Bar" ) {
...
}
}

That helps?

Matias
http://staff.southworks.net/blogs/matiaswoloski