Re: Unsubscribing from events.
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 03/15/05
- Next message: glenn: "class library problem"
- Previous message: Nicholas Paldino [.NET/C# MVP]: "Re: .NET Remoting/Serialization way too slow vs C++ binary/tcp"
- In reply to: Pete Davis: "Unsubscribing from events."
- Next in thread: Pete Davis: "Re: Unsubscribing from events."
- Reply: Pete Davis: "Re: Unsubscribing from events."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Mar 2005 10:29:21 -0500
Pete,
Yes, it works. I wouldn't waste the field to hold onto this. It's the
method that is the identity of the delegate, not the instance of the
delegate itself.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Pete Davis" <pdavis68@NOSPAM.hotmail.com> wrote in message
news:87adnUDn277vYKvfRVn-ow@giganews.com...
>I came across the following code in the .NET Framework:
>
> ((IBindingList) list).ListChanged -= new
> ListChangedEventHandler(this.List_ListChanged);
>
> In other places, they hold onto a reference to the original event handler
> instance and unsubscribe that. I've always held the references and
> unsubscribed the original myself.
>
> Unsubscribing from a new instance instead of the original instance just
> seems wrong. Yet one of my co-workers claims this actually works. Does it?
>
> Pete
>
>
- Next message: glenn: "class library problem"
- Previous message: Nicholas Paldino [.NET/C# MVP]: "Re: .NET Remoting/Serialization way too slow vs C++ binary/tcp"
- In reply to: Pete Davis: "Unsubscribing from events."
- Next in thread: Pete Davis: "Re: Unsubscribing from events."
- Reply: Pete Davis: "Re: Unsubscribing from events."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|