Strange Event Behavior

  • Thread starter Thread starter Dave Swersky
  • Start date Start date
D

Dave Swersky

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
 
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.
 
Back
Top