how to delegate ?

  • Thread starter Thread starter Hugo Mind
  • Start date Start date
H

Hugo Mind

Does someone knows how I could add an additional parameter to en event.
See the code below : event are fired but I need to know from which object
the event came.

Could someone explain with a code example please ?

Thank you in advance,

Example:

for (int i = 0; i < 10; i++)
{
agnphone = new SIMPLEPHONECTRLLib.PhoneClass();
agnphone.CallStateChanged += new
SIMPLEPHONECTRLLib._DPhoneEvents_CallStateChangedEventHandler(InvadeControl_CallStateChanged);
}

private void InvadeControl_CallStateChanged(int CallHandle, int CallState,
int StateDependantInfo, int Privilege)
{
staticlogger.sLog(5,0, "EVENT :: CallState has changed for handle : " +
CallHandle.ToString());
}
 
Hugo,

Instead of sending in parms, why not create an Arguments class inheriting
from the EventArgs class. That way, you can add more parms without changing
the signatures of the methods that listen to the events.

public class MyEventArgs : EventArgs
{
public int parm1;
public int parm2;
public string parm3;

... etc
}

change your delegate signature to:

public delegate DPhoneEvents_CallStateChangedEventHandler(object sender,
MyEventArgs e);

Let us know if that works for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top