Are multiple events expensive?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob

    Are multiple events expensive?

    Hi,
    I have a newbie question on event listening. I have a form that is
    monitoring progress in an application. The application consists of
    many classes, multithreaded, etc. The form listens for events on the
    main executing class, which in turn listens for events on classes it
    uses, etc, so that an event might have to propagate through several
    layers of event listeners and new events to make its way back to the
    form. I am wondering whether this is computationally expensive (ie
    raising multiple events) or if it is an ok way to program?

    Thanks,
    Bob

  • Alberto Poblacion

    #2
    Re: Are multiple events expensive?

    "Bob" <bshumsky06@yah oo.comwrote in message
    news:1174523491 .302751.255730@ l77g2000hsb.goo glegroups.com.. .
    I have a newbie question on event listening. I have a form that is
    monitoring progress in an application. The application consists of
    many classes, multithreaded, etc. The form listens for events on the
    main executing class, which in turn listens for events on classes it
    uses, etc, so that an event might have to propagate through several
    layers of event listeners and new events to make its way back to the
    form. I am wondering whether this is computationally expensive (ie
    raising multiple events) or if it is an ok way to program?
    Listening for an event does not have any cost, that is, nothing happens
    until the event is fired. When the events are raised, the cost is roughly
    equivalent to method calls (imagine that instead of using an event that
    raises another event you had a method that called another method, and so
    on).

    Comment

    • Bob

      #3
      Re: Are multiple events expensive?

      On Mar 22, 2:01 am, "Alberto Poblacion" <earthling-
      quitaestoparaco ntes...@poblaci on.orgwrote:
      "Bob" <bshumsk...@yah oo.comwrote in message
      >
      news:1174523491 .302751.255730@ l77g2000hsb.goo glegroups.com.. .
      >
      I have a newbie question on event listening. I have a form that is
      monitoring progress in an application. The application consists of
      many classes, multithreaded, etc. The form listens for events on the
      main executing class, which in turn listens for events on classes it
      uses, etc, so that an event might have to propagate through several
      layers of event listeners and new events to make its way back to the
      form. I am wondering whether this is computationally expensive (ie
      raising multiple events) or if it is an ok way to program?
      >
      Listening for an event does not have any cost, that is, nothing happens
      until the event is fired. When the events are raised, the cost is roughly
      equivalent to method calls (imagine that instead of using an event that
      raises another event you had a method that called another method, and so
      on).
      Great, thanks!

      Comment

      • Jon Davis

        #4
        Re: Are multiple events expensive?

        Event delegate assignments take up some memory, as delegates themselves and
        the containment of them in an event subscription stack aren't free, but a
        handful of delegate assignments won't matter.

        As Alberto mentioned, the performance hit is on the delegates' executions.
        There, the impact is more or less measurable by how often your event
        handlers are executed and what exactly they do.

        Jon


        "Bob" <bshumsky06@yah oo.comwrote in message
        news:1174523491 .302751.255730@ l77g2000hsb.goo glegroups.com.. .
        Hi,
        I have a newbie question on event listening. I have a form that is
        monitoring progress in an application. The application consists of
        many classes, multithreaded, etc. The form listens for events on the
        main executing class, which in turn listens for events on classes it
        uses, etc, so that an event might have to propagate through several
        layers of event listeners and new events to make its way back to the
        form. I am wondering whether this is computationally expensive (ie
        raising multiple events) or if it is an ok way to program?
        >
        Thanks,
        Bob
        >

        Comment

        Working...