public static void FooCallBack(IAsyncResult ar)
        {
            PrintCurrThreadInfo("FooCallBack()");
            AsyncFoo caller = (AsyncFoo)ar.AsyncState;

            caller.EndInvoke(ar);
        }
Example #2
0
    static void FooCallBack(IAsyncResult ar)
    {
        AsyncFoo caller = (AsyncFoo)ar.AsyncState;
        int      i      = caller.EndInvoke(ar);

        PrintCurrThreadInfo("FooCallBack() " + i.ToString() + "  ");
    }
Example #3
0
        static void Main(string[] args)
        {
            AsyncFoo foo = (UInt64 size) =>
            {
                UInt64 f = 1;
                for (UInt64 i = 2, tmp; i <= size; i++)
                {
                    try { checked { tmp = f * i; } }
                    catch (Exception)
                    {
                        Console.WriteLine("Overflow, max value returned");
                        return(f);
                    }
                    f *= i;
                }
                return(f);
            };

            UInt64 n = 21U;

            foo.BeginInvoke(n, (ar) => { Console.WriteLine(foo.EndInvoke(ar)); }, null);

            Console.ReadKey();
        }