Exemplo n.º 1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                if (bankSimulator == null)
                {
                    bankSimulator = new BankSimulator();
                }

                bankSimulator.Initialize(listBoxHelper, Convert.ToDecimal(txtBankAmount.Text), Convert.ToInt32(txtNumCustomers.Text),
                                         Convert.ToInt32(txtNumTellers.Text), Convert.ToDecimal(txtGoalAmt.Text),
                                         Convert.ToDecimal(txtMaxTransAmt.Text), Convert.ToDecimal(txtInitialAmt.Text));
                bankSimulator.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception occured:\n" + ex.Message);
            }
        }
Exemplo n.º 2
0
        public Bank(BankSimulator bankSim, ListBoxHelper listBoxHelper, ManualResetEvent workQuitEvent, decimal bankAmt, int numCustomers, int numTellers, decimal goalAmt, decimal maxTransAmt, decimal initialCustAmt)
        {
            _bankSim      = bankSim;
            _numCustomers = numCustomers;
            _numTellers   = numTellers;

            _goalAmt        = goalAmt;
            _maxTransAmt    = maxTransAmt;
            _initialCustAmt = initialCustAmt;

            _workQuitEvent  = workQuitEvent;
            _listBoxHelper  = listBoxHelper;
            _workReadyEvent = new ManualResetEvent(false);
            _workReadyEvent.Reset();

            _bankQueue = new BankQueue(_workReadyEvent);

            CreateTellerList(_numTellers);
            CreateCustomerList(_numCustomers);

            _vault         = new Vault(_workReadyEvent, this);
            _vault.Balance = bankAmt;
        }