Exemple #1
0
        static void Main(string[] args)
        {
            var producentKonsument = new PK();

            Console.WriteLine(producentKonsument.HasloKonsumenta);
            while (true)
            {
                var tasks = new List <Task>();
                tasks.Add(Task.Run(() => {
                    producentKonsument.producent();
                }));
                Console.WriteLine(producentKonsument.haslo);
                tasks.Add(Task.Run(() => {
                    producentKonsument.konsument();
                }));
                tasks.Add(Task.Delay(100));
                Task.WaitAll(tasks.ToArray());
                //Console.ReadKey();
                if (producentKonsument.koniec())
                {
                    break;
                }
            }
            Console.ReadKey();
        }
Exemple #2
0
 static void Main(string[] args)
 {
     var producentKonsument = new PK();
     Console.WriteLine(producentKonsument.HasloKonsumenta);
     while(true) {
         var tasks = new List<Task>();
         tasks.Add(Task.Run(() => {
             producentKonsument.producent();
         }));
         Console.WriteLine(producentKonsument.haslo);
         tasks.Add(Task.Run(() => {
             producentKonsument.konsument();
         }));
         tasks.Add(Task.Delay(100));
         Task.WaitAll(tasks.ToArray());
         //Console.ReadKey();
         if(producentKonsument.koniec())
             break;
     }
     Console.ReadKey();
 }