|
-
May 8th, 2009, 10:01 AM
#1
API defines public delegate.. huh?
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.
-
May 8th, 2009, 10:16 AM
#2
Re: API defines public delegate.. huh?
you need to something that looks like the next
Code:
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);
}
-
May 8th, 2009, 11:08 AM
#3
Re: API defines public delegate.. huh?
that worked.. thanks for the help!
-
May 8th, 2009, 11:26 AM
#4
Re: API defines public delegate.. huh?
You can also just write:
Code:
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;
}
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
-
May 9th, 2009, 03:51 AM
#5
Re: API defines public delegate.. huh?
 Originally Posted by Mutant_Fruit
You can also just write:
Code:
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 :-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|