Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            int[,] graph =
            {
                { 0,  6, 0,  0,  0,  0, 0,  9, 0 },
                { 6,  0, 9,  0,  0,  0, 0, 11, 0 },
                { 0,  9, 0,  5,  0,  6, 0,  0, 2 },
                { 0,  0, 5,  0,  9, 16, 0,  0, 0 },
                { 0,  0, 0,  9,  0, 10, 0,  0, 0 },
                { 0,  0, 6,  0, 10,  0, 2,  0, 0 },
                { 0,  0, 0, 16,  0,  2, 0,  1, 6 },
                { 9, 11, 0,  0,  0,  0, 1,  0, 5 },
                { 0,  0, 2,  0,  0,  0, 6,  5, 0 }
            };
            int[,]  graph1 =
            {
                { 1, 1, 1, 1 },
                { 0, 1, 1, 1 },
                { 0, 1, 0, 1 },
                { 1, 1, 9, 1 },
                { 0, 0, 1, 1 }
            };


            Dijkstra.DijkstraAlgo(graph1, 0, 4);


            Print("Before test ");
            var t = new TestDelegate((x) =>
            {
                Print(x.ToString());
            });
            IAsyncResult  re = null;
            AsyncCallback ac = (r) => { };

            t.BeginInvoke(10234324, ac, null);
            t.EndInvoke(re);
            new InvokeDelegate().InvokeDelegates();
            var c = new EventConsumer();

            c.DoWork();
            End();
            return;

            //Console.WriteLine(RemainingDays());

            Console.WriteLine("Welcome");
            Console.WriteLine("Main Thread " + Thread.CurrentThread.ManagedThreadId + " Is Background " + Thread.CurrentThread.IsBackground);
            var async = new Async();

            /*
             * async.TestMethod();
             * Console.WriteLine("will this come before or after: ");
             * Console.WriteLine("________________________________________________________");
             * Console.WriteLine("Main Thread " + Thread.CurrentThread.ManagedThreadId + " Is Background " + Thread.CurrentThread.IsBackground);
             * TestMethodAsync(async);
             * Print(" Should return immediately : Async will this come before or after: ");
             */
            var sum = TestAddAsync(async);

            Print("Main method sum " + sum.Result);

            try
            {
                var res = Task.Factory.StartNew <int>(() => async.ErrorMethod("mainmethodAsynInput"));
                if (res.IsFaulted)
                {
                    Print(res.Exception.Message);
                }
                var r = res.Result;
            }
            catch (Exception e)
            {
                Print("Mainmethod Exception " + e.Message);
            }

            try
            {
                var res = ErrorAsync(async);

                var r = res.Result;
            }
            catch (Exception e)
            {
                Print("Mainmethod Exception for error async " + e.Message);
            }


            End();
        }