Saturday, March 24, 2012
Strange Event Behavior
Scenario:
Class A has a method that returns an instantiated object of Class B.
Class A has a Public Event called "DataUpdated".
When the Class A method is called to return an instance of Class B,
Class A hands to Class B a pointer to itself. Therefore, Class B can
reference the instance of Class A that instantiated it.
Thus, Class B can call the DataUpdated event on the instance of Class A
that instantied it. A method of Class A marked "Friend", called
OnDataUpdated, is called when the "Save" method of Class B is called.
Weirdness:
This all works as planned, but strangely. In an ASP.NET application,
I'm storing an instance of Class A in the Cache. When I call the "Save"
method on Class B, the event bubbles up to the instance of Class A as
expected. However, the event fires up to five times. I've stepped
through the code; the event is only raised once.
Any ideas? Thanks.
Dave Swersky
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Is it a special needs class?
Try giving them a longer recess. It will allow them to expend some energy
before they return to your classroom.
Labels:
asp,
behavior,
class,
dataupdated,
event,
instantiated,
method,
net,
object,
public,
returns,
scenarioclass,
strange
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment