public TransactionGenerator(UIHelper uiHelper, CancellationToken ct, BankQueue bq, CustomerList cl, decimal maxTransactionAmount, int timeoutThrottle)
        {
            try
            {
                this.uiHelper = uiHelper;
                this.cancelToken = ct;
                this.maxTransAmount = maxTransactionAmount;
                if (cl == null)
                {
                    uiHelper.GeneralMessage("DEBUG: The 'cl' (CustomerList) IS NULL!!!!");
                }
                this.customerList = cl;

                if (timeoutThrottle < 1) timeoutThrottle = 1;
                this.timeoutThrottle = timeoutThrottle;

                this.bankQueue = bq;

                this.task = Task.Factory.StartNew(TransactionGeneratorProc, cancelToken);
            }
            catch(Exception ex)
            {
                uiHelper.GeneralMessage("Exception in the Transaction Generator().  Message=" + ex.Message);
            }
        }
Beispiel #2
0
 public Bank(UIHelper uiHelper, CancellationToken ct, int numTellers, int numCustomers, decimal custInitialAmount, decimal initialBankVaultBalance)
 {
     BankQueue = new BankQueue(ct);
     Customers = new CustomerList(numCustomers, custInitialAmount, uiHelper);
     Vault = new BankVault(initialBankVaultBalance);
     tellerList = new List<Teller>();
     for (int i = 0; i < numTellers; i++)
     {
         tellerList.Add(new Teller(uiHelper, ct, this));
     }
 }
        public TransactionGenerator(UIHelper uiHelper, CancellationToken cancelToken, BankQueue bankQueue, CustomerList customerList, int maxTransAmount, int timeOutThrottle,
                                    /*List<Teller> tellers,*/ BlockingCollection <Teller> tellers, Bank bank)
        {
            this.cancelToken     = cancelToken;
            this.customerList    = customerList;
            this.maxTransAmount  = maxTransAmount;
            this.uiHelper        = uiHelper;
            this.timeOutThrottle = timeOutThrottle;
            this.bankQueue       = bankQueue;
            this.bank            = bank;

            currentTranAmount = 0;
            rand               = new Random();
            this.tellers       = tellers;
            availTellerQueue   = new BlockingCollection <Teller>();
            unAvailTellerQueue = new BlockingCollection <Teller>();

            foreach (Teller tel in tellers)
            {
                availTellerQueue.Add(tel);
            }


            task = new Task(Generate);
            task.Start();
        }