Consider the following class:
public class Event<T>
{
public delegate void Handler<t>(t msg);
private event Handler<T> E;
public void connect(Delegate handler) {
E += delegate(T msg) {
object target = handler.Target;
if (Invokable(target) {
target.BeginInvoke(handler, new object[] { msg });
}
};
}
public void emit(T msg) {
if ( E != null ) {
E(msg);
}
}
private static bool Invokable(object o) {
// magic
}
}
How do I implement Invokable()
, and what else do I need for this code to compile? The only other problem that I know of is the target.BeginInvoke
call, since target is object
.