Beispiel #1
0
        private static void Example1()
        {
            var externalData = "some external data";

            Console.WriteLine("Hello World!");

            AddictionDelegate add = Add;

            Console.WriteLine("Executed on thread (Main()) ThreadId: " + Thread.CurrentThread.ManagedThreadId);

            IAsyncResult result;

            // .NET Core throw exception, because
            result = add.BeginInvoke(10, 5, new AsyncCallback(AddComplete), externalData);

            var operationResult = add.EndInvoke(result);

            Console.ReadKey();
        }
Beispiel #2
0
        private static void Example1()
        {
            var externalData = "some external data";

            Console.WriteLine("Hello World!");

            AddictionDelegate add = Add;

            Console.WriteLine("Executed on thread (Main()) ThreadId: " + Thread.CurrentThread.ManagedThreadId);

            IAsyncResult result;

            // As you see we dont manually create threads here, ThreadPool take care of this
            result = add.BeginInvoke(10, 5, new AsyncCallback(AddComplete), externalData);

            var operationResult = add.EndInvoke(result);

            Console.ReadKey();
        }