static void Main(string[] args)
    {
        int          x      = 0;
        int          input  = 10;
        Foo          f      = SampleFoo;
        IAsyncResult result = f.BeginInvoke(ref input, "Hello", null, null);

        f.EndInvoke(ref x, result);
        Console.WriteLine("Result: {0}", x);     // 5
    }
Пример #2
0
        protected static IAsyncResult dlgt_BeginInvoke(Foo dlgt, TestRfcommPort port, PORT_EV eventId,
                                                       AsyncCallback callback, object state)
        {
#if true || PocketPC
            FooParams args = new FooParams(dlgt, port, eventId);
            AsyncNoResult <FooParams> ar = new AsyncNoResult <FooParams>(callback, state, args);
            ThreadPool.QueueUserWorkItem(dlgt_Runner, ar);
            return(ar);
#else
            arDlgt = dlgt.BeginInvoke(port, eventId, null, null); // NETCF-ok
#endif
        }