Beispiel #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            timer1.Start();

            folderBrowserDialog1.ShowDialog();
            string name = folderBrowserDialog1.SelectedPath;

            if (name == null || name == "")
            {
                return;
            }
            button5.Enabled = false;
            button6.Enabled = true;
            button2.Enabled = false;
            button1.Enabled = false;

            try
            {
                Directory.CreateDirectory(name);
                multiThread = new MultiThreads(panel.table, Int32.Parse(Value_NumberOfThreads.Text), Int32.Parse(Value_NumberOfStaticBricks.Text), name);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
                return;
            }

            if (textBox1.Text.Length / 4 != Int32.Parse(Value_NumberOfStaticBricks.Text))
            {
                textBox1.Text = multiThread.GetFirstStaticBoardState();
            }

            multiThread.LatestStaticBoard = textBox1.Text;
            multiThread.StartObserver();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //1 - Collections, Generics, Exceptions, Interfaces
            //ExceptionExample.TestMethod();
            //GenericArrayExample.TestMethod();
            //Collections.TestMethod();

            //2 - Delegates, Events, LINQ - Language - Integrated Query
            //DelegatesExample.testings();
            //Events.TestMethod();
            //SampleCollection<String>.TestMethod();
            //Events.TestMethod();
            //LINQExample.TestMethod();
            //OperatorOverloading.TestMethod();

            //4 - Assemblies, Type reflection, Late binding, and Attribute Programming
            //Assemblies.TestMethod(); //Prints out a message, that is generated from a AssemblyExample.dll
            //Type_Reflection.TestMethod();
            //LateBinding.TestMethod();
            //Attributes.TestMethod();
            //Attributes.TestMethod();

            //5 – AppDomains, Multi-threads and parallel programming
            MultiThreads.TestMethod();
            MultiThreads.TestJoin();
            MultiThreads.TestPassingData();
            MultiThreads.TestWithPriority();
            MultiThreads_Locks.TestWithoutLock();
            MultiThreads_Locks.TestWithLock();
            MultiThreads_Locks.TestWithMonitor();
            Tasks.TestMethod();
            Tasks.TestWithAsyncAndAwait();
            Tasks.TestInParallel();

            //6 - LINQ to XML
            //SerializeTest.CreateXmlFile();
            //SerializeTest.ReadSavedXmlFile();
            //XMLToLINQExample.LoadXml();

            //7 - Dynamic Values
            //DynamicExample.TestMethod();
            //DynamicAssemblyExample.TestMethod();
            //C: \Users\NicolaiLarsen\source\repos\CsExam\CsExam\Examples\6 - LINQ To XML



            // .GetFolderPath()).FullName;



            // string path = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName;
            //Console.WriteLine("Press any key to exit");
            //Console.ReadLine();
        }
        static void Main(string[] args)
        {
            CancellationTokenSource cancellation = new CancellationTokenSource();
            CancellationToken       token        = cancellation.Token;

            bool working = true;

            while (working)
            {
                System.Console.Write("Choose what you want to see: \n1.Matrix\n2.Threads\n3.Async\n4.Parallel\nExit\nChoose: ");
                int choice;
                int seconds = 1000;
                if (int.TryParse(Console.ReadLine(), out choice))
                {
                    switch (choice)
                    {
                    case 1:
                    {
                        //! shows matrix
                        showMatrix(token);
                        seconds = 7000;
                    }
                    break;

                    case 2:
                    {
                        Console.Clear();
                        //! Inserts data to array
                        MultiThreads.insertID(100);
                        seconds = 1000;
                    }
                    break;

                    case 3:
                    {
                        Console.Clear();
                        //! Does calculations async
                        showCalculationAsync(5);
                        seconds = 1000;
                    }
                    break;

                    case 4:
                    {
                        System.Console.WriteLine("Parallel");
                        Parallel1.executeNumberCounter();
                        seconds = 2000;
                    }
                    break;

                    case 5:
                    {
                        working = false;
                    }
                    break;
                    }
                }

                if (choice == 3)
                {
                    Console.CursorTop = 10;
                }
                if (choice != 3)
                {
                    Thread.Sleep(seconds);
                    Console.Clear();
                }
            }

            Console.ReadKey();
        }