Exemplo n.º 1
0
 public Form1()
 {
     InitializeComponent();
     par                 = new Parametres();
     par.r               = new Random(System.DateTime.Now.Millisecond);
     st                  = new Storage();
     customs             = new List <Customer>();
     threads             = new List <Thread>();
     par.purchasesAmount = new int[customersAmount];
     for (int i = 0; i < customersAmount; i++)
     {
         par.purchasesAmount[i] = 0;
     }
 }
Exemplo n.º 2
0
        public void Work(Object parr)
        {
            Parametres par = parr as Parametres;

            while (Storage.f)
            {
                Thread.Sleep(1);
                TakeAnItems(par.r);
                int t = 0;
                for (int i = 0; i < customersAmount; i++)
                {
                    t = (par.purchasesAmount[customerNumber] - par.purchasesAmount[i]) > t ? (par.purchasesAmount[customerNumber] - par.purchasesAmount[i]) : t;
                }
                if (t <= 0)
                {
                    MakeAPurchase(par.purchasesAmount);
                }
            }

            outpDel(customerNumber, par.purchasesAmount[customerNumber], sumItemsAmount);
        }