?
Solved

delegates and dispose

Posted on 2003-02-23
2
Medium Priority
?
429 Views
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?
0
Comment
Question by:bryanwells
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
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.

Smg.
0
 

Author Comment

by:bryanwells
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.  

0

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 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