6
6tc1
Hi all, I'm inquiring about the mechanism that is used to implement
event handlers in .NET (not really relevant, but I'm using C#).
Anyway, I've noticed that I can pass an object in an event argument and
if the receiver (event handler) of that event changes any of the
properties in that object, then the original object I passed is
changed. I.E. it seems as if events are passed by reference and not by
value. This certainly frees me up from trying to optimize memory usage
when I'm passing objects (or actually their references) through event
arguments.
I was thinking that events were serialized - but it seems that isn't
the case. Since if they were being serialized then any changes made to
the object by the event handler shouldn't affect the original that was
passed as an argument.
Hope this is clear - the reason I'm asking this is because I have a
rather large object that I'm passing as an event argument and I was
going through the code in an attempt to optimize only to realize that
there doesn't appear to be any performance benefit to passing a unique
identifier string for that object and then find that object in my
database or whether I just pass this entire massive object.
Thanks,
Novice
event handlers in .NET (not really relevant, but I'm using C#).
Anyway, I've noticed that I can pass an object in an event argument and
if the receiver (event handler) of that event changes any of the
properties in that object, then the original object I passed is
changed. I.E. it seems as if events are passed by reference and not by
value. This certainly frees me up from trying to optimize memory usage
when I'm passing objects (or actually their references) through event
arguments.
I was thinking that events were serialized - but it seems that isn't
the case. Since if they were being serialized then any changes made to
the object by the event handler shouldn't affect the original that was
passed as an argument.
Hope this is clear - the reason I'm asking this is because I have a
rather large object that I'm passing as an event argument and I was
going through the code in an attempt to optimize only to realize that
there doesn't appear to be any performance benefit to passing a unique
identifier string for that object and then find that object in my
database or whether I just pass this entire massive object.
Thanks,
Novice