المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Delegate casting/conversion



C# Programming
08-21-2010, 11:40 PM
I have a method that takes a SendOrPostCallback delegate as a parameter.
public void Post(SendOrPostCallback sendOrPostCallback)
{
// ...
}
I want to overload this method and instead take a MethodInvoker delegate.
public void Post(MethodInvoker methodInvoker)
{
// ...
}
The problem is this second method needs to convert the MethodInvoker to a SendOrPostCallback using null for the state parameter so it can call the original method.

I can't figure out how to do this http://www.barakasoft.com/script/Forums/Images/smiley_confused.gif
DaveIf this helped, please vote & accept answer!

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon (http://www.codeproject.com/Members/Pete-OHanlon))
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn (http://www.codeproject.com/Members/Luc-Pattyn))