Clearing an Event

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

    Clearing an Event

    A quick question...

    In my program I handle an event, but the way it is programed the event gets "handled" twice. Is there a way to clear the event after it is handled the first time

    Thank
    Brad
  • Cor Ligthert

    #2
    Re: Clearing an Event

    Hi Brad,

    You can either set a switch (the most simple method) or otherwise remove the
    handler temporary (the most difficult method).

    Did you know the static keyword which is very usable for a switch, with that
    you do not have to set it public but can keep it in your procedure something
    as.

    static myswitch as boolean

    if myswitch then
    'do what you want
    myswitch = false

    I hope this helps?

    Cor


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Clearing an Event

      * "=?Utf-8?B?QnJhZA==?=" <anonymous@disc ussions.microso ft.com> scripsit:[color=blue]
      > In my program I handle an event, but the way it is programed the event
      > gets "handled" twice. Is there a way to clear the event after it is
      > handled the first time.[/color]

      If your event is called 'Foo', then you can use 'FooEvent' to get "more
      options". There you can get the 'InvocationList ', add handlers
      ('Combine') and remove handlers using 'Remove'.

      --
      Herfried K. Wagner [MVP]
      <URL:http://dotnet.mvps.org/>

      Comment

      Working...