Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Okay, I know what byVal and byRef do, ByVal passes a copy of an object, and ByRef passes the actual object, but lets say I have this code:

 

Class myTest
Event myEvent(ByVal sender as myTest)
sub FireEvent()
RaiseEvent myEvent(me)
end sub
End Class

sub RunTest()
dim mTest as new myTest
addhandler mTest.myEvent, addressof del_myEvent
mTest.FireEvent
end sub

sub del_myEvent(byval sender as myTest)
RemoveHandler sender.myEvent,addressof del_myevent
end sub

 

Will the object mTest's handler be unassigned correctly? Or since i've passed a copy of the object, the original will still fire again? Should I just stick to writing everything byref instead? My application seems to eat up alot of memory, because something is getting stuck and not used. It uses a similar structure to the code above. Any tips?

 

Any help would be appreciated. Thanks. :confused:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...