What I am trying to do is be able to pass a function reference to another function and have it used as a callback method for a System.Threading.ThreadPool.QueueUserWorkItem.
See in method D() the ‘Any’ parameter.
I need to be able to pass the callback method pointer or reference for the ‘Any’ parameter. I can’t use a delegate, because that would need to be static, is that correct?
Any ideas?
private void A() { /*code*/ }
private void B() { /*code*/ }
private void C(int i)
{
switch(i)
{
case 1:
D(A());
break;
case 2:
D(B());
break;
default:
break;
}
}
private void D(type? Any)
{
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(Any));
}
I think this will do what you want, but WaitCallback delegates take an object as a parameter.