We can call callback methods using delegates. For instance,
public delegate bool ContinueProcessing ();
// later in the code we can write
ContinueProcessing cp = new ContinueProcessing (IsDataAvailable);
cp + = new ContinueProcessing (IsTransactionComplete);
// later in the method code definition
bool IsDataAvailable () {return true; }
bool IsTransactionComplete () {return true; }
cp.Invoke ();
The above call will call two Boolean methods one after another. Why do we need "events"? What is the purpose of "events"?
source
share