An Event Publication must be of type EventHandler ?

Topics: CAB & Smart Client Software Factory
Sep 11, 2007 at 7:25 PM
hi, i am trying to make an event publication in a class registered as a service, but an exeption occure saying that the event must be of type EventHandler or EventHandler(Of T)

(my event is not of type EventHandler) ?

I can't make my event of type EventHandler(of T) because i am trying to make "e" a business object that doew not inherit from EventArgs !
Sep 12, 2007 at 12:09 AM
class EventArgsThatContainMyEObject : EventArgs {
public MyBusenessObject myBusinessObject;
// constructor, et al.
};

EventPublisher("topic://myevent")
public event EventHandler<EventArgsThatContainMyEObject> SomethingImportantHasHappened;

or something...
Sep 12, 2007 at 2:01 AM
If you want to pass a business object as an argument for an EventBroker event then you should use the EventArgs<T> class, like so:

[EventPublication(EventTopicNames.SendSomeData, PublicationScope.Global)]
public void SendSomeData(object sender, EventArgs<MyBusinessObject> e);

Then you can use it like this:

private void SendData(MyBusinessObject obj)
{
   if(SendSomeData != null)
      SendSomeData(this, new EventArgs<MyBusinessObject>(obj));
}