Example #1
0
        static void Main(string[] args)
        {
            Stack <FileInfo> fileInfos = new Stack <FileInfo>();

            fileInfos = FileFinder.DirSearch("..\\..\\..\\files", "txt");

            ThreadMaker threadMaker = new ThreadMaker(10);

            ThreadMaker.fileInfos = fileInfos;
            threadMaker.MakeThreads();

            Thread.Sleep(2000);
            Console.WriteLine("Нажмите любую клавишу, чтобы увидеть результаты");

            Console.ReadKey();

            ThreadModel.generalDictionary = ThreadModel.generalDictionary.SaveTenLargestValues();

            foreach (KeyValuePair <string, int> entry in ThreadModel.generalDictionary)
            {
                Console.WriteLine("word - {0}, count - {1}", entry.Key, entry.Value);
            }

            Console.ReadKey();
        }
Example #2
0
        /*public delegate void Del(string s);
         * public static void DelMethod(string s)
         * {
         *  WriteLine(s);
         * }*/

        static void Main(string[] args)
        {
            /*Del handler = DelMethod;
             * handler("print sth");*/

            Stopwatch z1 = new Stopwatch();
            Stopwatch z2 = new Stopwatch();
            Stopwatch z3 = new Stopwatch();
            Stopwatch z4 = new Stopwatch();

            ThreadMaker s1 = Silnia;

            Thread t1 = new Thread(() =>
            {
                Silnia(100000);
            });

            Thread t2 = new Thread(() =>
            {
                s1(100000);
            });



            WriteLine("z1 startuje");
            z1.Start();
            t1.Start();

            WriteLine("z2 startuje");
            z2.Start();
            t2.Start();

            t1.Join();
            z1.Stop();
            WriteLine("Bez delegata wyliczono w: " + z1.Elapsed);

            t2.Join();
            z2.Stop();
            WriteLine("Z delegatem wyliczono w: " + z2.Elapsed);

            WriteLine("z3 startuje");
            z3.Start();
            Silnia(100000);
            WriteLine("z3: " + z3.Elapsed);

            WriteLine("z4 startuje");                   //+delegat
            z4.Start();
            s1(100000);
            WriteLine("z4: " + z4.Elapsed);

            ReadKey();
        }