• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

event registration

hi - I have a winform application and .net 4, using VS2010. the application uses a tab control to organize itself. all the code is written around which tab you're on and each tab runs a method as it is loads. the load method queries a database and draws the appropriate number of controls as it loads. since some of the controls are dependent on the query, I have to create them on entry and refer to them in the code using winhandles. as part of the process I also register an event for the controls. so, my question is two fold - is there any harm in having the same event be registered multiple times (each time the tab is invoked?); and after an indeterminate length of time, the binding between the event and the event handler seems to drop. any idea why?
should I be disposing of the controls as I leave the tab?
thanks.
0
jdcoburn
Asked:
jdcoburn
1 Solution
 
AndyAinscowCommented:
>>is there any harm in having the same event be registered multiple times
Apart from the obvious one - for the one event many pieces of code will be run.

For the other question about the binding being dropped - I've no idea why you experience that.
0
 
jdcoburnAuthor Commented:
ok - I think you answered the question I should have asked - each time the event is registered it creates a new copy which results in multiple passes through the code.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now