FWIW, here's a slightly simpler version of my AsyncHelper work around in
support of fire-and-forget.  It just leverages
ThreadPool.QueueUserWorkItem instead of async delegates against
delegates :-)

public class AsyncHelper
{
    class TargetInfo
    {
        internal TargetInfo( Delegate d, object[] args )
        {
            Target = d;
            Args = args;
        }

        internal readonly Delegate Target;
        internal readonly object[] Args;
    }

    private static WaitCallback dynamicInvokeShim = new
WaitCallback(DynamicInvokeShim);

    public static void FireAndForget( Delegate d, params object[] args )
    {
        ThreadPool.QueueUserWorkItem(dynamicInvokeShim, new
TargetInfo(d, args));
    }

    static void DynamicInvokeShim( object o )
    {
        TargetInfo ti = (TargetInfo)o;
        ti.Target.DynamicInvoke(ti.Args);
    }
}

-Mike
DevelopMentor
http://staff.develop.com/woodring

Reply via email to