|
-
Apr 26th, 2004, 01:55 PM
#1
Thread Starter
yay gay
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/
-
Apr 26th, 2004, 02:40 PM
#2
PowerPoster
Yes, you use '-=' to unregister your event handlers.
-
Apr 27th, 2004, 06:41 AM
#3
Thread Starter
yay gay
\m/  \m/
-
Apr 27th, 2004, 08:58 PM
#4
Frenzied Member
Originally posted by PT Exorcist
but i put -= what?
Same as above code, just change the += to -=
-
Apr 29th, 2004, 09:43 AM
#5
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.
-
May 4th, 2004, 11:48 AM
#6
Thread Starter
yay gay
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|