Results 1 to 6 of 6

Thread: Removing event handlers

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Removing event handlers

    I a function which will add some events:
    _parent.Plugins.Plugins.PvtPlugin.SendPrivMessage(_user, "XDCC SEND " + _trigger);
    _parent.Plugins.Plugins.ChannelPlugin.ChannelJoined += new Branco.Irc.Plugins.ChannelPlugin.ChannelJoinedHandler(ChannelPlugin_ChannelJoined);
    _parent.NewMessage += new Branco.Irc.IrcClient.NewMessageHandler(_parent_NewMessage);
    _parent.Plugins.Plugins.DccReceivePlugin.FileSendRequest += new Branco.Irc.Plugins.DccReceivePlugin.DccIncommingConnectionHandler(DccReceivePlugin_FileSendRequest);
    _parent.Plugins.Plugins.DccReceivePlugin.FileSendRequest
    Now, at a certain time I'll want to stop "listening" to the events...maybe it's something that uses -=?

    Thanks in advance
    \m/\m/

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Yes, you use '-=' to unregister your event handlers.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    but i put -= what?
    \m/\m/

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Originally posted by PT Exorcist
    but i put -= what?
    Same as above code, just change the += to -=

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You need to store the event handlers somewhere else, though.

    Code:
    Branco.Irc.Plugins.ChannelPlugin.ChannelJoinedHandler handler =
        new Branco.Irc.Plugins.ChannelPlugin.ChannelJoinedHandler(ChannelPlugin_ChannelJoined);
    _parent.Plugins.Plugins.ChannelPlugin.ChannelJoined += handler;
    _parent.Plugins.Plugins.ChannelPlugin.ChannelJoined -= handler
    That's the safe way to go about it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah, that's what i was asking about
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width