Пример #1
0
        static async Task Main(string[] args)
        {
            switch (InterfaceFunctions.ChooseSection <ConcurrentSection>())
            {
            case ConcurrentSection.Multithreaded:
            {
                Multithreads.Multithreaded();
            }
            break;

            case ConcurrentSection.Tasks:
            {
                Multithreads.Tasks();
            }
            break;

            case ConcurrentSection.TasksWithResult:
            {
                Multithreads.TasksResult();
            }
            break;

            case ConcurrentSection.Timers:
            {
                Timers.TimersTest();
            }
            break;

            case ConcurrentSection.PLINQ:
            {
                ParallelLINQ.PLINQExample();
            }
            break;

            case ConcurrentSection.PLINQOrdered:
            {
                ParallelLINQ.PLINQExampleOrdered();
            }
            break;

            case ConcurrentSection.Async:
            {
                Asynchronous.AsyncTest();
                // Ker await ne blokira izvajalne niti, pred izračunom pridemo iz funkcije
                Console.WriteLine("Smo na koncu primera!");
                // Vrstni red čakanja na input ni popolnoma jasen...
                //Thread.Sleep(3000);
                Console.ReadLine();
            }
            break;

            case ConcurrentSection.AsyncSeveral:
            {
                string keyword = "in";
                Asynchronous.AsyncTestSeveral(keyword);
                Console.WriteLine($"Program se vmes nadaljuje...");
            }
            break;

            case ConcurrentSection.AsyncFiles:
            {
                AsyncFiles.AsyncFilesTest();
            }
            break;

            case ConcurrentSection.AsyncFilesCancel:
            {
                AsyncFiles.AsyncFilesTestWithCancel();
            }
            break;

            case ConcurrentSection.AsyncFilesProgress:
            {
                AsyncFiles.AsyncFilesTestWithCancelAndProgress();
            }
            break;

            case ConcurrentSection.Lock:
            {
                LockAndMonitor.LockExample();
            }
            break;

            case ConcurrentSection.ComputePI:
            {
                ComputePI.ComputePITests();
            }
            break;

            case ConcurrentSection.BreakfastBad:
            {
                PrepareBreakfastAsync.BreakfastBadExample();
            }
            break;

            case ConcurrentSection.BreakfastGood:
            {
                //PrepareBreakfastAsync.BreakfastBadExample();
                await PrepareBreakfastAsync.BreakfastGoodExample();
            }
            break;
            }
            Console.ReadLine();
        }
Пример #2
0
        static async Task Main(string[] args)
        {
            Section section = Section.BreakfastGood;

            Console.WriteLine();
            switch (section)
            {
            case Section.Multithreaded:
            {
                Multithreads.Multithreaded();
            }
            break;

            case Section.Tasks:
            {
                Multithreads.Tasks();
            }
            break;

            case Section.TasksWithResult:
            {
                Multithreads.TasksResult();
            }
            break;

            case Section.Timers:
            {
                Timers.TimersTest();
            }
            break;

            case Section.PLINQ:
            {
                ParallelLINQ.PLINQExample();
            }
            break;

            case Section.PLINQOrdered:
            {
                ParallelLINQ.PLINQExampleOrdered();
            }
            break;

            case Section.Async:
            {
                Asynchronous.AsyncTest();
            }
            break;

            case Section.AsyncSeveral:
            {
                string keyword = "fiš";
                Asynchronous.AsyncTestSeveral(keyword);
            }
            break;

            case Section.AsyncFiles:
            {
                AsyncFiles.AsyncFilesTest();
            }
            break;

            case Section.AsyncFilesCancel:
            {
                AsyncFiles.AsyncFilesTestWithCancel();
            }
            break;

            case Section.AsyncFilesProgress:
            {
                AsyncFiles.AsyncFilesTestWithCancelAndProgress();
            }
            break;

            case Section.Lock:
            {
                LockAndMonitor.LockExample();
            }
            break;

            case Section.ComputePI:
            {
                ComputePI.ComputePITests();
            }
            break;

            case Section.BreakfastBad:
            {
                PrepareBreakfastAsync.BreakfastBadExample();
            }
            break;

            case Section.BreakfastGood:
            {
                //PrepareBreakfastAsync.BreakfastBadExample();
                await PrepareBreakfastAsync.BreakfastGoodExample();
            }
            break;
            }
            Console.ReadLine();
        }