Hi,
I want to do two types of async callbacks in C#. One involves spawning a
worker thread, and the other does not invlve threads:
Case 1 (Span new thread)
----------------------------
class Fred {
private MyParams params = null ;
/* ctors and dtor*/
public Fred(){;}
~Fred(){;}
void foo() {
params = getConfig();
/* Spawn worker thread that will
notify me when completed */
asynchWorker(methodToInvoke, params, myCallback);
}
void methodToInvoke(MyParams p, MyCallBack cb){
//Do something ..
}
//How do you implement MyCallback, in C++ we have functors
// and in C we have function pointers. How is it done
// in C# ?
}
Case 2 (same thread)
This allows me to register a callback so that
Barney can act like a facade pattern
-------------------------------------------
class Barney {
private MyCallback myCall = null ;
/* ctors and dtor*/
public Barney(){;}
~Barney(){;}
void registerCallback(MyCallBack cb) {
if (cb != null) myCall = cb ;
return;
}
//How do you implement MyCallback, in C++ we have functors
// and in C we have function pointers. How is it done
// in C# ?
}