Example #1
0
        public void Run()
        {
            const int nCount = 45;

            var counter = new Stopwatch();

            fact = new DelegateType(FibonacciRec);
            fib  = new DelegateType(FibonacciIter);

            counter.Start();

            fact.Invoke(nCount);
            fib.Invoke(nCount);

            counter.Stop();

            Console.WriteLine("Synch: " + counter.Elapsed);

            counter.Reset();
            counter.Start();

            var factAsync = fact.BeginInvoke(nCount, null, null);
            var fibAsync  = fib.BeginInvoke(nCount, null, null);

            fact.EndInvoke(factAsync);
            fib.EndInvoke(fibAsync);

            counter.Stop();

            Console.WriteLine("Asynch: " + counter.Elapsed);
        }
Example #2
0
 public void Pair(DelegateType <V> method)
 {
     if (method != null)
     {
         foreach (KeyValuePair <uint, V> item in m_DicTable)
         {
             method.Invoke(item.Value);
         }
     }
 }
Example #3
0
        public static async Task OperationTask(object data)
        {
            Console.WriteLine("Begin task");
            await Task.Run(() =>
            {
                Console.WriteLine("begin async");
                Thread.Sleep(100);
                DelegateType foo = (x, y) => x = y;
                foo.Invoke(20, 7);
                Console.WriteLine("end async");
            });

            Console.WriteLine("end task");
        }