|
-
Aug 10th, 2002, 06:20 PM
#1
*Resolved* Do I have to remove event handlers?
Right now I'm adding this to a process:
VB Code:
AddHandler Process.Exited, AddressOf Process_Exited
Process.EnableRaisingEvents = True
Now when the process is exited (or when I exit my app), should I go ahead and use RemoveHandler to remove the event handler? or it doesnt really mather?
Last edited by MrPolite; Aug 12th, 2002 at 05:40 PM.
-
Aug 11th, 2002, 06:54 AM
#2
Frenzied Member
If you dont want the event to be raised again, you should remove it.
Dont gain the world and lose your soul
-
Aug 12th, 2002, 03:38 PM
#3
Originally posted by DevGrp
If you dont want the event to be raised again, you should remove it.
well the thing is that I'm closing my program and so the event wont be raised I'm just wondering if it is bad to leave it like that (without removing it)
-
Aug 12th, 2002, 05:27 PM
#4
PowerPoster
No, you can leave it. See when a forms constructor is called when it is being created, the initialize method is called. That is where VS puts all the code to initialize all the controls on the form and their associated events. It does the same code you would do when you add in your event handlers, just it is in the initialize method. When your form is destroyed (you exit your app) all instance data is destroyed with it, so it doesn't matter if you have event handlers. They are just delegates anyway, an object that the garbage collector will handle for you.
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
|