B
Bruce Wood
Maybe I'm going nuts, but I was so sure that adding the same method
more than once to a delegate would result in only one entry on the
delegate's call list:
this.UpdateEnd += new EventHandler(UpdateStockCode);
this.UpdateEnd += new EventHandler(UpdateStockCode);
if (this.UpdateEnd != null)
{
this.UpdateEnd(this, System.EventArgs.Empty);
}
would result in only one call to UpdateStockCode(). However, it results
in two.
How do I ensure that there is only ever one copy of the method on the
delegate list, so that the method is only called once? Do I have to do
this:
this.UpdateEnd -= new EventHandler(UpdateStockCode);
this.UpdateEnd += new EventHandler(UpdateStockCode);
this.UpdateEnd -= new EventHandler(UpdateStockCode);
this.UpdateEnd += new EventHandler(UpdateStockCode);
?
more than once to a delegate would result in only one entry on the
delegate's call list:
this.UpdateEnd += new EventHandler(UpdateStockCode);
this.UpdateEnd += new EventHandler(UpdateStockCode);
if (this.UpdateEnd != null)
{
this.UpdateEnd(this, System.EventArgs.Empty);
}
would result in only one call to UpdateStockCode(). However, it results
in two.
How do I ensure that there is only ever one copy of the method on the
delegate list, so that the method is only called once? Do I have to do
this:
this.UpdateEnd -= new EventHandler(UpdateStockCode);
this.UpdateEnd += new EventHandler(UpdateStockCode);
this.UpdateEnd -= new EventHandler(UpdateStockCode);
this.UpdateEnd += new EventHandler(UpdateStockCode);
?