Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


delegates and dispose

Posted on 2003-02-23
Medium Priority
Last Modified: 2009-07-29
If I declare an event using a delegate and I add event listeners to the event, what happens if one or more of the event listeners are distroyed?  Do I have to always remove the event listener from the event object, or is this done for me if an event listener is destroyed?
Question by:bryanwells
LVL 10

Accepted Solution

smegghead earned 150 total points
ID: 8003958
If this is using remoting then you definetely have to unsubscribe the event.. otherwise it attempts to send an event to a process which is no longer listening and bombs out. This then prevents all other subscribers from receiving your event. You can trap the error and itterate the 'InvocationList' to determine which subscriber is causing you the problem.

If it's not using remoting then I'd imagine that you might be lucky.. best thing to do is try it.


Author Comment

ID: 8004671
I am not using remoting right now, but things worked much better when I was careful to remove all delegate event listeners when they were destroyed.  I thought that garbage collection might take care of this.  


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question