Пример #1
0
 static void Main(string[] args)
 {
     Demo1.Run();
     Demo2.Run();
     Demo3.Run();
     Demo4.Run();
     Demo5.Run();
 }
Пример #2
0
        static void Main()
        {
            // const int numberTasks = 2;
            // const int partitionSize = 1000000;
            // const int loops = 5;
            // var taskResults = new Dictionary<int, int[][]>();
            // var data = new List<string>[loops];
            // for (int i = 0; i < loops; i++)
            // {
            //     data[i] = new List<string>(FillData(partitionSize * numberTasks));
            // }

            // var barrier = new Barrier(1);
            // LogBarrierInformation("initial participants in barrier", barrier);

            // for (int i = 0; i < numberTasks; i++)
            // {
            //     barrier.AddParticipant();

            //     int jobNumber = i;
            //     taskResults.Add(i, new int[loops][]);
            //     for (int loop = 0; loop < loops; loop++)
            //     {
            //         taskResults[i][loop] = new int[26];
            //     }
            //     Console.WriteLine($"Main - starting task job {jobNumber}");
            //     Task.Run(() => CalculationInTask(jobNumber, partitionSize, barrier, data, loops, taskResults[jobNumber]));
            // }

            // for (int loop = 0; loop < 5; loop++)
            // {
            //     LogBarrierInformation("main task, start signaling and wait", barrier);
            //     barrier.SignalAndWait();
            //     LogBarrierInformation("main task waiting completed", barrier);
            //     //                var resultCollection = tasks[0].Result.Zip(tasks[1].Result, (c1, c2) => c1 + c2);
            //     int[][] resultCollection1 = taskResults[0];
            //     int[][] resultCollection2 = taskResults[1];
            //     var resultCollection = resultCollection1[loop].Zip(resultCollection2[loop], (c1, c2) => c1 + c2);

            //     char ch = 'a';
            //     int sum = 0;
            //     foreach (var x in resultCollection)
            //     {
            //         Console.WriteLine($"{ch++}, count: {x}");
            //         sum += x;
            //     }

            //     LogBarrierInformation($"main task finished loop {loop}, sum: {sum}", barrier);
            // }

            // Console.WriteLine("at the end");
            // Console.ReadLine();


            Demo2.Run();
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Demo1 d = new Demo1();
            //d.Run();
            Demo2 d2 = new Demo2();

            d2.Run();

            EventPublisher p = new EventPublisher();

            EventSubscriber1 s1 = new EventSubscriber1();
            EventSubscriber2 s2 = new EventSubscriber2();


            p.Added += s1.AddedEventHandler;
            p.Added += s2.AddedEventHandler;

            p.Add(50);
        }