Click to See Complete Forum and Search --> : API defines public delegate.. huh?


zackb
May 8th, 2009, 10:01 AM
C# noob here. Wondering if anyone out there could shed some light on dealing with this API. I'm using .net 3.5.

The API method is defined in the object browser as:
public delegate int CallbackMessage(long userData, int nToolId, int nStatus, string pMessage)

When I try the following code:
CallbackMessage myCall = new CallbackMessage(); //i know this is wrong, looking at intellisense

The intellisense on CallbackMessage constructor is telling me:
CallbackMessage.CallbackMessage( int (long, int, int, string) target);

How would I build a constructor for myCall? Thanks in advance.

dannystommen
May 8th, 2009, 10:16 AM
you need to something that looks like the next



private void myCallbackHandler(long userData, int nToolId, int nStatus, string pMessage){
//do something with the values
}

private void Test(){
//make a call to the API
CallbackMessage.CallbackMessage += new CallbackMessage(myCallbackHandler);
}

zackb
May 8th, 2009, 11:08 AM
that worked.. thanks for the help!

Mutant_Fruit
May 8th, 2009, 11:26 AM
You can also just write:


private void myCallbackHandler(long userData, int nToolId, int nStatus, string pMessage){
//do something with the values
}

private void Test(){
//make a call to the API
CallbackMessage.CallbackMessage += myCallbackHandler;
}

dannystommen
May 9th, 2009, 03:51 AM
You can also just write:


private void myCallbackHandler(long userData, int nToolId, int nStatus, string pMessage){
//do something with the values
}

private void Test(){
//make a call to the API
CallbackMessage.CallbackMessage += myCallbackHandler;
}


Didn't know that :-)