How do I find out if an object can be Invoke()'d?
- by Jurily
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?