How do I find out if an object can be Invoke()'d?

Posted by Jurily on Stack Overflow See other posts from Stack Overflow or by Jurily
Published on 2010-06-18T12:20:57Z Indexed on 2010/06/18 12:23 UTC
Read the original article Hit count: 204

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about events